C# 有没有反序列化protobuf基类的捷径
我正在使用protobuf net 2.3.2.0版C# 有没有反序列化protobuf基类的捷径,c#,serialization,protocol-buffers,protobuf-net,C#,Serialization,Protocol Buffers,Protobuf Net,我正在使用protobuf net 2.3.2.0版 [ProtoContract(ImplicitFields = ImplicitFields.AllFields)] [ProtoInclude(12, typeof(SubClass))] public class BaseClass { public string Id { get; set; } public string Name { get; set; } } [ProtoContract(ImplicitFiel
[ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
[ProtoInclude(12, typeof(SubClass))]
public class BaseClass
{
public string Id { get; set; }
public string Name { get; set; }
}
[ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
public class SubClass : BaseClass
{
public string PropertySub { get; set; }
}
因为我的基类是从许多子类继承的。
如何避免在基类上放置属性
[ProtoInclude]
,以便基类中的道具按预期反序列化。据我所知,没有。但是您可以在运行时完全构建您的模型(使用反射探索您的类)。@Evk Ok。。让我检查一下。谢谢据我所知没有。但是您可以在运行时完全构建您的模型(使用反射探索您的类)。@Evk Ok。。让我检查一下。谢谢