我做错了什么?
[JsonObject(MemberSerialization.OptOut)]
public class Parent
{
public int ParentID {get;set;}
}
[JsonObject(MemberSerialization.OptOut)]
public class Child
{
public int ChildID { get; set;}
}
[JsonObject(MemberSerialization.OptOut)]
public class Container
{
[JsonProperty(TypeNameHandling = TypeNameHandling.All)]
public List<Parent> Objects {get; set;}
}
ContainerInstance.Objects.Add(new Child());
var mem = new MemoryStream();
var writer = new BsonWriter(mem);
var reader = new BsonReader(mem);
var serializer = new JsonSerializer();
serializer.TypeNameAssemblyFormat =
System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full;
serializer.Serialize(writer, ContainerInstance);
mem.Position = 0;
var deserializedContainerInstance = serializer.Deserialize<Nute>(reader);
// WHERE IS THE CHILDID?
deserializedContainerInstance.Object;