public void Serialize(SerializationStream stream, ArchiveMode mode)
        {
            // Check version number (should be 0 for now, for future use)
            if (mode == ArchiveMode.Serialize)
            {
                stream.Write(0);
            }
            else if (mode == ArchiveMode.Deserialize)
            {
                if (stream.ReadInt32() != 0)
                    throw new InvalidOperationException("Unexpected version number.");
            }

            // Serialize content
            stream.Serialize(ref IsBinary);
            if (IsBinary)
            {
                stream.Serialize(ref BinaryFormat);
                stream.Serialize(ref Binary, mode);
            }
            else
            {
                stream.Serialize(ref Profile);
                stream.Serialize(ref EntryPoint);
                stream.Serialize(ref Source);
            }
        }
Esempio n. 2
0
 public static SerializationStream Write([NotNull] this SerializationStream stream, byte[] values, int offset, int count)
 {
     stream.Serialize(values, offset, count);
     return(stream);
 }
Esempio n. 3
0
 public static SerializationStream Write([NotNull] this SerializationStream stream, sbyte value)
 {
     stream.Serialize(ref value);
     return(stream);
 }
Esempio n. 4
0
 public static SerializationStream Write(this SerializationStream stream, char value)
 {
     stream.Serialize(ref value);
     return(stream);
 }
Esempio n. 5
0
 public static byte[] ReadBytes(this SerializationStream stream, int count)
 {
     byte[] value = new byte[count];
     stream.Serialize(value, 0, count);
     return(value);
 }