public static List <T> Decode <T>(IEnumerator <Frame> iterator, DecodeDelegate <T> decodeFunction) { var result = new List <T>(); //begin frame, list iterator.Take(); while (!iterator.AtStructEnd()) { result.Add(decodeFunction(iterator)); } //end frame, list iterator.Take(); return(result); }
public static List <T> DecodeContainsNullable <T>(IEnumerator <Frame> iterator, DecodeDelegate <T> decodeFunction) where T : class { var result = new List <T>(); //begin frame, list iterator.Take(); while (!iterator.AtStructEnd()) { result.Add(iterator.SkipNull() ? null : decodeFunction(iterator)); } //end frame, list iterator.Take(); return(result); }
public static IDictionary <TKey, TValue> Decode <TKey, TValue>(IEnumerator <Frame> iterator, DecodeDelegate <TKey> decodeKey, DecodeDelegate <TValue> decodeValue) { var result = new Dictionary <TKey, TValue>(); //begin frame, map iterator.Take(); while (!iterator.AtStructEnd()) { var key = decodeKey(iterator); var value = decodeValue(iterator); result[key] = value; } //end frame, map iterator.Take(); return(result); }
// public static void EncodeNullable<TKey, TValue>(ClientMessage clientMessage, IEnumerable<KeyValuePair<TKey, TValue>> collection, // Action<ClientMessage, TKey> encodeKeyFunc, // Action<ClientMessage, TValue> encodeValueFunc) // { // if (collection == null) // { // clientMessage.Add(NullFrame.Copy()); // } // else // { // Encode(clientMessage, collection, encodeKeyFunc, encodeValueFunc); // } // } public static IList <KeyValuePair <TKey, TValue> > Decode <TKey, TValue>(IEnumerator <Frame> iterator, DecodeDelegate <TKey> decodeKeyFunc, DecodeDelegate <TValue> decodeValueFunc) { var result = new List <KeyValuePair <TKey, TValue> >(); //begin frame, map iterator.Take(); while (!iterator.AtStructEnd()) { var key = decodeKeyFunc(iterator); var value = decodeValueFunc(iterator); result.Add(new KeyValuePair <TKey, TValue>(key, value)); } //end frame, map iterator.Take(); return(result); }