i'm using protobuf-net and i like it so far but one thing is bugging me. I have a class that i would like to use in a message but its not in my source.
like so:
[ProtoContract]
class Test{
[ProtoMember(1)]
public Otherclass Attr {get;set}
}
but ProtoBuf does not know how to serialize Otherclass and i cant access the code of it.
So i need to tell it how to do it but h开发者_Go百科ow?In v1 you can't, unless it happens to have xmlaerializer or datacontractserializer attributes. Well, that isn't quite true... There is a GlobalOptions toggle that should work in theory, but is not very tolerant if the type changes, as it is inferring a lot.
The better option here is to look at "v2", which is available as an alpha download. Your attributed types should be fine, but you can also tell the type-model how to handle unattributed types; this is all via RuntimeTypeModel.
精彩评论