private static object Deserialize(Type expected, BinaryTokenStreamReader stream) { DeserializeCounter++; var result = new ClassWithCustomSerializer(); result.IntProperty = stream.ReadInt(); result.StringProperty = stream.ReadString(); return result; }
private static object Deserialize(Type expected, BinaryTokenStreamReader stream) { DeserializeCounter++; var result = new ClassWithCustomSerializer(); result.IntProperty = stream.ReadInt(); result.StringProperty = stream.ReadString(); return(result); }
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); }
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 }