admin 管理员组

文章数量: 1087652

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?

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)