C# 在protobuf中初始化派生类的序列化
我正在使用protobuf。我有一个抽象类base1.cs和另一个类ListofItems.cs,它有base1列表和一些其他属性 这就是我初始化序列化程序的方式C# 在protobuf中初始化派生类的序列化,c#,protobuf-net,C#,Protobuf Net,我正在使用protobuf。我有一个抽象类base1.cs和另一个类ListofItems.cs,它有base1列表和一些其他属性 这就是我初始化序列化程序的方式 private static MetaType Actualmodel; static Initserialization() { var Model = TypeModel.Create(); Model.Add(typeof (EventMessage), tru
private static MetaType Actualmodel;
static Initserialization()
{
var Model = TypeModel.Create();
Model.Add(typeof (EventMessage), true);
Actualmodel= Model.Add(typeof (base1), true);
ProtobufSerializer.Models.Add(typeof(ListofItems), Model);
}
我有一堆从base1.cs继承的对象,一切正常。
现在我添加了另一个从base1继承的类base2.cs。如何更新初始化以包含此base2
在下面尝试,但不起作用
Actualmodel= Model.Add(typeof (base1), true).AddSubType(500,typeof(base2));
谢谢 你说“不起作用”:会发生什么?没有什么?例外?你的电脑冒黑烟然后死掉?给我一个线索;plol“不起作用”的意思是我的意思是它起作用了nothing@user570715:没有多少行代码“什么也不做”。你可能应该试着更具体一些。理想情况下,提供一个中断的测试或可以重现问题的东西