public void DeserializeTypeWithPrivateReadonlyDictionary_DCS() { var before = new ClassWithPrivateReadonlyDictionary(Guid.NewGuid()); before.GetBody()["name"] = "my name"; DataContractSerializer dcs = new DataContractSerializer(typeof(ClassWithPrivateReadonlyDictionary)); var ms = new MemoryStream(); dcs.WriteObject(ms, before); ms.Position = 0; var after = (ClassWithPrivateReadonlyDictionary)dcs.ReadObject(ms); Assert.Equal("my name", after.GetBody()["name"]); }
public void DeserializeTypeWithPrivateReadonlyDictionary() { var before = new ClassWithPrivateReadonlyDictionary(Guid.NewGuid()); before.GetBody()["name"] = "my name"; byte[] bytes = MessagePackSerializer.Serialize(before, StandardResolverAllowPrivate.Options); string json = MessagePackSerializer.ConvertToJson(bytes); // just for check that json has _body' values. this.logger.WriteLine(json); var after = MessagePackSerializer.Deserialize <ClassWithPrivateReadonlyDictionary>(bytes, StandardResolverAllowPrivate.Options); Assert.Equal("my name", after.GetBody()["name"]); }