开发者

how to serialize a class implements two interfaces who have same based interface

I am trying use protobuf v2 to serialize a class A implements interfaces B and C. And both B and C derived from D.


[ProtoBuf.ProtoContract]
[ProtoBuf.Includes(101, typeof(B))
[ProtoBuf.Includes(101, typeof(C))
interface D{...}

[ProtoBuf.ProtoContract]
[ProtoBuf.开发者_JS百科Includes(101, typeof(A))
interface B:interfae D{...}

[ProtoBuf.ProtoContract]
[ProtoBuf.Includes(101, typeof(A))
interface C:interface D
{
   ...
}

[ProtoBuf.ProtoContract]
class A: interface B, interface C{...}

There will return error: a type can only participate in one inheritance hierarchy.


Interfaces are not really the same kind of "derived" (inheritance) as class inheritance. While basic interface support is provided, this is not a scenario that protobuf-net currently supports.

As to whether it could support it - that would take some thought. I would suggest logging a request, here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜