Ejemplo n.º 1
0
        // 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());
        }
Ejemplo n.º 2
0
        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);
        }