The main task is to dynamically populate the Dictionary object and serialize it using Protobuf-net and send it through the client side WCF service.
@marc Can you tell me some sample code on how I can resolve the "Nested or uneven lists and arrays are not supported" error when I try to serialize using Protobuf-net.
[Serializable] [ProtoContract] public class DynamicWrapper { [ProtoMember(1)] public List<Dictionary<string, string>> Items { get; set; } public DynamicWrapper() { Items = new List<Dictionary<string, string>>(); } } public class Service1 : IService1 { public byte[] GetData(string sVisibleColumnList) { DynamicWrapper dw = new DynamicWrapper(); Dictionary<string, string> d = new Dictionary<string, string>(); d.Add("CUSIP", "123456"); dw.Items.Add(d); d = new Dictionary<string, string>(); d.Add("ISIN", "456789"); dw.Items.Add(d); var ms = new MemoryStream(); var model = ProtoBuf.Meta.RuntimeTypeModel.Default; model.Serialize(ms, dw); Serializer.Serialize <DynamicWrapper>(ms, dw); return ms.GetBuffer(); } }
c # protocol-buffers protobuf-net
Ram
source share