public void WriteDictionary(IDictionary dictionary) { var dictionaryGenerics = dictionary.GetType().GetGenericArguments(); var keys = ListUtils.CreateListOfType(dictionaryGenerics[0]); var values = ListUtils.CreateListOfType(dictionaryGenerics[1]); dictionary.Keys.CopyToList(keys); dictionary.Values.CopyToList(values); WriteList(keys); WriteList(values); }
public IList ReadList(Type listType) { var count = ReadNumber(); var listGenericType = listType.GetGenericArguments().Single(); if (listGenericType == typeof(object)) { throw LogUtils.Throw("Cannot read a List<object>"); } var list = ListUtils.CreateListOfType(listGenericType); for (var i = 0; i < count; i++) { list.Add(Serializer.Deserialize(listGenericType, RemainingBuffer, out var consumed)); BufferIndex += consumed; } return(list); }