问题
I just replaced .NET serialization with protocol buffers in a distributed cache application and the results are really impressive. The only thing I do not like is the fact that I need to add dependencies between a base message class and its children which creates a circular dependency. Is there an alternative to tagging base class with ProtoInclude?
回答1:
In v1; [ProtoInclude]
is the only way to support inheritance.
In v2, you can use MetaType
's .AddSubType(...)
method to achieve the same thing, without requiring your base-type to know about the derived type(s).
来源:https://stackoverflow.com/questions/1231789/protoinclude-adds-unwanted-dependencies