protobuf-netの継承機能に関する多くの質問を読みました。[ProtoContract]、[ProtoMember]と同じように[DataContract]、[DataMember]を使用できるのではないかと思います。[ProtoInclude]の代わりに[KnowType]を使用できないのはなぜですか?
すでにprotobuf-netのシリアル化に[DataContract]、[DataMember]を使用しているので、この質問を提起します。「Protobuf-net」を追加する必要はありませんでした。「System.Runtime.Serialization」のみを使用しました。
しかし...クラスが何らかのクラスから継承する必要がある場合、[ProtoInclude]属性に「Protobuf-net」を追加する必要がありますか?例えば、
using System.Runtime.Serialization;
namespace test
{
[DataContract]
/// [KnowType(typeof(SomeClass))]
/// or
/// [ProtoInclude(100,typeof(SomeClass))]
public class BaseClass
{
//...
[DataMember(Order=1)]
public string BlahBlahBlah {get; set;}
}
[DataContract]
public class ChildClass1 : BaseClass
{
//...
[DataMember(Order=1)]
public string BlahBlahBlah {get; set;}
}
}// end namespace
最後に、私は100の子クラスを持っているのだろうか、基本クラス内に100の[ProtoInclude]タグを追加することに夢中になりませんか?
助けのためのadvのThx
ヴィー