Binary encoding and decoding of Security objects – permissions, permission sets, policy levels and their code groups – uses standard binary serialization. Custom code need do nothing special to support binary serialization, which is handled via reflection as it is for all kinds of objects. Refer to System.Serialization classes for details.
The following pseudo-code shows how the encoding and decoding process works for security objects.
// Encode security object obj to Stream stream BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize( stream, obj ); // Decode security object obj from Stream stream BinaryFormatter formatter = new BinaryFormatter(); obj = formatter.Deserialize( stream );