我有一本动态的字典。
public Dictionary<int, dynamic> Data = new Dictionary<int, dynamic>();
动态部分将包含仅由5-6个get/set属性组成的简单类,例如,这些类看起来就像这样。
public class Class1
{
public int Property1 { get; set; }
public int Property2 { get; set; }
}和
public class Class2
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}我尝试将这两个类添加到我的字典中,然后序列化字典,但收到一个错误。我只是想知道Protobuf.Net是否能够序列化和反序列化这样的字典?如果是这样的话,这是如何实现的?
发布于 2013-04-02 19:04:01
简短的回答是“不是真的”。可能有一些方法可以让它工作,但我不建议这样做-它将很难维护。
当序列化程序预先知道结构时,protobuf-net (通常也是protobuf )工作得最好。
https://stackoverflow.com/questions/15741797
复制相似问题