开发者

.net Binary Serialization - Opt In

  • I am doing Binary Serilization of big nested data structure.
  • Whenever [Serilizable] attribute is added to class, all the members are automatically serialized.
  • I want to specifically select the fields that need to be serialized.
  • As of now i am using [NonSerialized] Attribute for fields to opt out from serilization.

  • Is there any way i can opt out all fields by default and then select only the fields i need, by usin开发者_JS百科g some attribute ?


You can control the serialization yourself by implementing ISerializable and writing a serialization constructor. For more information, read this article.


If you use the DataContractSerializer, all the fields will be opted out by default. You will then be able to opt in your desired field using attributes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜