private static object Deserialize(Type expected, BinaryTokenStreamReader stream)
 {
     DeserializeCounter++;
     var result = new ClassWithCustomSerializer();
     result.IntProperty = stream.ReadInt();
     result.StringProperty = stream.ReadString();
     return result;
 }
示例#2
0
        private static object Deserialize(Type expected, BinaryTokenStreamReader stream)
        {
            DeserializeCounter++;
            var result = new ClassWithCustomSerializer();

            result.IntProperty    = stream.ReadInt();
            result.StringProperty = stream.ReadString();
            return(result);
        }
示例#3
0
        private static object Deserialize(Type expected, IDeserializationContext context)
        {
            DeserializeCounter++;
            var result = new ClassWithCustomSerializer();
            var stream = context.StreamReader;

            result.IntProperty    = stream.ReadInt();
            result.StringProperty = stream.ReadString();
            return(result);
        }
示例#4
0
        public void Serialize_CustomSerializer()
        {
            var original = new ClassWithCustomSerializer()
            {
                IntProperty = -3, StringProperty = "Goodbye"
            };
            var writeStream = new BinaryTokenStreamWriter();

            SerializationManager.Serialize(original, writeStream);
            Assert.Equal(1, ClassWithCustomSerializer.SerializeCounter); //Custom serializer was not called

            var readStream = new BinaryTokenStreamReader(writeStream.ToBytes());
            var obj        = SerializationManager.Deserialize(readStream);

            Assert.Equal(1, ClassWithCustomSerializer.DeserializeCounter); //Custom deserializer was not called
        }
        public void Serialize_CustomSerializer()
        {
            var original = new ClassWithCustomSerializer() { IntProperty = -3, StringProperty = "Goodbye" };
            var writeStream = new BinaryTokenStreamWriter();
            SerializationManager.Serialize(original, writeStream);
            Assert.Equal(1, ClassWithCustomSerializer.SerializeCounter); //Custom serializer was not called

            var readStream = new BinaryTokenStreamReader(writeStream.ToBytes());
            var obj = SerializationManager.Deserialize(readStream);
            Assert.Equal(1, ClassWithCustomSerializer.DeserializeCounter); //Custom deserializer was not called
        }