Reputation: 13
I'm new to protobuf-net and am wondering whether there is a possibility to influence which objects are serialized if i have an object graph and want to serialize only parts of it. I think of some sort of callback or stuff like that.
Upvotes: 1
Views: 273
Reputation: 1062955
Two standard (used by other frameworks) patterns are supported for conditional serialization - if we have:
public Foo SomeProperty {get;set}
Then either of:
public bool ShouldSerializeSomeProperty() {...}
Or:
public bool SomePropertySpecified {
get {...}
set {...}
}
Should work fine. Return true to serialise, false to ignore. Depending on your target framework, it can also usually be non-public if desired.
Upvotes: 1