ProtoInclude 添加不需要的依赖项 [英] ProtoInclude adds unwanted dependencies

查看:37
本文介绍了ProtoInclude 添加不需要的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在分布式缓存应用程序中用协议缓冲区替换了 .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?

推荐答案

In v1;[ProtoInclude] 是唯一支持继承的方式.

In v1; [ProtoInclude] is the only way to support inheritance.

在 v2 中,您可以使用 MetaType.AddSubType(...) 方法来实现相同的功能,而无需您的基本类型知道派生类型.

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

这篇关于ProtoInclude 添加不需要的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆