How to add a class to protobuf-net
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}
}
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.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论