コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: BinaryReader.cs プロジェクト: Akronae/Proteus
        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);
        }