public static Dictionary <TKey, TValue> GetDictionary <TKey, TValue>(this NetDataReader reader) { int count = reader.GetInt(); Dictionary <TKey, TValue> result = new Dictionary <TKey, TValue>(); for (int i = 0; i < count; ++i) { result.Add(reader.GetValue <TKey>(), reader.GetValue <TValue>()); } return(result); }
public static object GetArray(this NetDataReader reader, Type type) { int count = reader.GetInt(); Array array = Array.CreateInstance(type, count); for (int i = 0; i < count; ++i) { array.SetValue(reader.GetValue(type), i); } return(array); }
public static List <TValue> GetList <TValue>(this NetDataReader reader) { int count = reader.GetInt(); List <TValue> result = new List <TValue>(); for (int i = 0; i < count; ++i) { result.Add(reader.GetValue <TValue>()); } return(result); }
public static TValue[] GetArray <TValue>(this NetDataReader reader) { int count = reader.GetInt(); TValue[] result = new TValue[count]; for (int i = 0; i < count; ++i) { result[i] = reader.GetValue <TValue>(); } return(result); }