Пример #1
0
            public PropertyToken(PropertyInfo property)
            {
                this.Property  = property;
                this.Converter = ConfigurationUtility.GetConverter(property);

                var attribute = property.GetCustomAttribute <ConfigurationPropertyAttribute>(true);

                if (attribute == null)
                {
                    this.Alias = property.Name;
                }
                else
                {
                    this.Alias = attribute.Name;
                }
            }
Пример #2
0
        private void SetDictionaryValue(object dictionary, IConfigurationSection configuration)
        {
            if (configuration.Value == null)
            {
                foreach (var child in configuration.GetChildren())
                {
                    this.SetDictionaryValue(dictionary, child);
                }
            }

            if (dictionary != null && Common.Convert.TryConvertValue(configuration.Value, _dictionaryType.GenericTypeArguments[1], () => ConfigurationUtility.GetConverter(_unrecognizedProperty), out var convertedValue))
            {
                Reflection.Reflector.SetValue(ref dictionary, "Item", convertedValue, new object[] { configuration.Key });
            }
        }