初始化protobuf中派生类的序列化

时间:2014-04-28 22:02:57

标签: c# protobuf-net

我正在使用protobuf。我有抽象类base1.cs和另一个类ListofItems.cs,它有base1列表和一些其他属性。

这是我初始化序列化程序的方法

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));

谢谢!

0 个答案:

没有答案
相关问题