Conditional serialization with protobuf-net

 ̄綄美尐妖づ 提交于 2019-12-12 17:19:58

问题


Is it possible to conditionally serialize a property from an object using protobuf-net?


回答1:


protobuf-net supports the standard conditional serializers patterns, so for property Foo, a method like bool ShouldSerializeFoo() or a property bool FooSpecified (with at least a getter) should work fine. These same techniques are supported my multiple serialization and UI frameworks.

Or more simply, for value-type properties, you can just use Nullable<T>. A null value will not be serialized.



来源:https://stackoverflow.com/questions/35469388/conditional-serialization-with-protobuf-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!