public void ComplexType_SerailizeAndBack_ValuesAreEqual() { var value = new Team { Name = "av_team", Memebers = new[] { new User { Name = "Kolya", Age = 24, IsFemale = false }, new User { Name = "Petya", Age = 2, IsFemale = false }, new User { Name = "Sasha", Age = 3, IsFemale = false } } }; using (var result = new MemoryStream()) { var primitiveSerializator = new ProtoSerializer <Team>(); primitiveSerializator.SerializeT(value, result); result.Position = 0; var deserialized = new ProtoDeserializer <Team>().DeserializeT(result, (int)result.Length); Assert.IsNotNull(deserialized); Assert.IsTrue(value.IsSameTo(deserialized)); } }
public void SimpleType_SerailizeAndBack_ValuesAreEqual() { var value = new User { Name = "Kolya", Age = 24, IsFemale = false }; using (var result = new MemoryStream()) { var primitiveSerializator = new ProtoSerializer <User>(); primitiveSerializator.SerializeT(value, result); result.Position = 0; var deserialized = new ProtoDeserializer <User>().DeserializeT(result, (int)result.Length); Assert.IsNotNull(deserialized); Assert.IsTrue(value.IsSameTo(deserialized)); } }
private CompiledSerializer(IProtoTypeSerializer head, TypeModel model) { this.head = head; this.serializer = CompilerContext.BuildSerializer(head, model); this.deserializer = CompilerContext.BuildDeserializer(head, model); }