【发布时间】:2017-03-27 12:02:52
【问题描述】:
我有一个关于 c# 中的 msgpack 序列化的问题。 我有一个基类和一个从基类派生的类,它们每个都持有属性,例如:
class Base
{
int PropertyA { get; set; }
}
class DerivedFromBase : Base
{
int PropertyB { get; set; }
}
另外我还有一个第三类Container的对象,例如:
class Container
{
Base ContainerProperty { get; set; }
}
我的问题是,如果 ContainerProperty 是 DerivedFromBase 类型,则 MsgPack 只序列化 PropertyA,而不是 PropertyB!我如何才能实现 MsgPack 在内部将 ContainerProperty 识别为 DerivedFromBase?我必须编写自定义序列化程序还是有“内置”方式?
谢谢。
【问题讨论】: