ProtoIninclude 添加了不需要的依赖项

发布于 2024-07-30 02:55:21 字数 129 浏览 3 评论 0原文

我刚刚在分布式缓存应用程序中用协议缓冲区替换了 .NET 序列化,结果非常令人印象深刻。 我唯一不喜欢的是,我需要在基本消息类及其子类之间添加依赖关系,这会创建循环依赖关系。 除了用 ProtoInclude 标记基类之外,还有其他选择吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吾性傲以野 2024-08-06 02:55:21

在 v1 中; [ProtoInclude] 是支持继承的唯一方法。

在 v2 中,您可以使用 MetaType.AddSubType(...) 方法来实现相同的目的,而不需要您的基类型知道派生类型( s)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文