Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我刚刚在分布式缓存应用程序中用协议缓冲区替换了 .NET 序列化,结果确实令人印象深刻。我唯一不喜欢的是我需要在基本消息类及其子类之间添加依赖关系,这会创建循环依赖关系。有没有用 ProtoInclude 标记基类的替代方法?
在 v1 中;[ProtoInclude]是支持继承的唯一方法。
[ProtoInclude]
在 v2 中,您可以使用MetaType'.AddSubType(...)方法来实现相同的目的,而无需您的基类型知道派生类型。
MetaType
.AddSubType(...)