// TODO: refactor codecs to work with IDictionary public static IList <KeyValuePair <Guid, IList <int> > > Decode(IEnumerator <Frame> iterator) { var ownerPartitionIds = ListMultiFrameCodec.Decode(iterator, ListIntegerCodec.Decode); var ownerIds = ListUUIDCodec.Decode(iterator); return((ownerIds, ownerPartitionIds).Combine() .Select(x => new KeyValuePair <Guid, IList <int> >(x.Item1, x.Item2)) .ToList()); }
public static void Encode(ClientMessage clientMessage, ICollection <KeyValuePair <Guid, ICollection <int> > > collection) { var keyList = new List <Guid>(collection.Count); clientMessage.Append(Frame.CreateBeginStruct()); foreach (var(ownerId, partitionIds) in collection) { keyList.Add(ownerId); ListIntegerCodec.Encode(clientMessage, partitionIds); } clientMessage.Append(Frame.CreateEndStruct()); ListUUIDCodec.Encode(clientMessage, keyList); }