Beispiel #1
0
        private TDictionary ConvertFrom(TomlTable table, ITomlSerializerContext context)
        {
            var dictionary = (TDictionary)Activator.CreateInstance(_instanceType) !;

            foreach (var key in table.Keys)
            {
                var value = table.TryGetValue(key, out var dictionaryValue)
                    ? _valueConverter.ConvertFrom(dictionaryValue, context)
                    : throw new InvalidOperationException("This should never happen");
                dictionary[key] = value;
            }

            return(dictionary);
        }
Beispiel #2
0
 ? (TCollection)_createCollection(tomlArray.Select(v => _itemConverter.ConvertFrom(v, context)))
 : throw new TomlException();
Beispiel #3
0
 public TNewType ConvertFrom(TomlObject value, ITomlSerializerContext context)
 => _constructor(_innerConverter.ConvertFrom(value, context));