I have a .NET type, which is attributed with neither ProtoContract nor DataContract. In addition, not all of its state need to be proto-serialized.
Can I define a .proto file for it, but at the same time use some kind of a Serializer to serialize it as though it is attributed with ProtoContract?
Thanks.
As a third option,
[XmlType]and[XmlElement(Order=n)]can be used… but I don’t think that is what you mean ;pIn “v2”, this is indeed possible. You don’t need to define a .proto – you can simply tell it what to do at runtime, for example:
now store
modelsomewhere (and re-use it), and usemodel.Serialize(...)andmodel.Deserialize(...). The above configuresSomeTypeto serialize.Foo(as field 1),.Bar(as field 2) and.Blip(as field 3). There are of course many more ways of doing this for more fine-grained control.It will generate (as first needed) a serializer (via IL emit, so very fast) that works with your types as expected.
There is a downloadable “v2” dll, but it needs updating – I have done a lot of fixes in the last few weeks. I will try to refresh this dll later today, or you can build from code.