admin管理员组文章数量:1435859
Maybe this is a nobrainer.
I have a tabular data structure where each row is represented by an object[]
. The data structure implements ITypedList
so I can even tell the exact type of each object in the array.
What would be the best way to use protobuf-net to serialize this object array?
Obviously I cannot just adorn it with [ProtoMember(1)]
.
Should I create my own value class like so
[ProtoContract]
public class ValueWrapper
{
[ProtoMember(1)] public int IntValue {get;set;}
[ProtoMember(2)] public string StringValue {get;set;}
[ProtoMember(3)] public bool BoolValue {get;set;}
[ProtoMember(4)] public AvailableTypes Type {get;set;}
}
and replace object[]
with ValueWrapper[]
or is there an easier, more streamlined (and less allocation-heavy?) way to do it?
本文标签:
版权声明:本文标题:c# - protobuf-net serialize object array when it only contains known types (int, string, decimal, etc.) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743900945a2558665.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论