We use protobuf.net to serialize classes between mobile devices and back end services, but now we need to configure what is sent back to the client based on the user's "context".
Usually we do this by implementing the ISerializable interface and consider the context value in order to later decide what to serialize. Similarly, in the constructor, we then deserialize the provided values.
But it looks like ISerializable is not implemented / supported (I don’t understand why) for protobuf.net, so we circumvented this by taking the approaches “ShouldSerialize *” and “OnSerializing”. However, this means that we ultimately have to store the StreamingContext in every class that doesn't seem right. We could use it on a global scale, but that is also not the case.
Is there a better way to achieve what we want, for example. serialization using protobuf.net format only, but does serialization depend on the external context?
c # serialization deserialization protobuf-net
jamie Apr 17 '12 at 11:15 2012-04-17 11:15
source share