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?

本文标签: