Пример #1
0
        public void GetElementType_GivenDictInputType_ReturnsCorrectElementType(Type input, Type _, Type expectedEleType)
        {
            // Act
            var eleType = DictReflectUtil.GetElementType(input);

            // Assert
            eleType.Should().Be(expectedEleType);
        }
        public object Convert(ITomlRoot root, object value, Type targetType)
        {
            var table       = (TomlTable)value;
            var ctx         = new TomlSettings.CreateInstanceContext((string)null);
            var converted   = (IDictionary)table.Root.Settings.GetActivatedInstance(targetType, ctx);
            var elementType = DictReflectUtil.GetElementType(converted.GetType());

            foreach (var r in table.Rows)
            {
                converted[r.Key] = r.Value.GetInternal(elementType, r.Key.ToEnumerable);
            }

            return(converted);
        }