Пример #1
0
        protected virtual object GetPropertyValue(object source, IPropertyConfig noLabelPropertyConfig)
        {
            MethodInfo genericMethod = NoLabelGetPropertyValueMethod.MakeGenericMethod(
                noLabelPropertyConfig.GetType().GetGenericArguments());

            return(genericMethod.Invoke(this, new object[] { source, noLabelPropertyConfig }));
        }
Пример #2
0
 protected internal ConfigProperty(IPropertyConfig config, [NotNull] String key, T defaultValue, Func <T, Boolean> validate, ICryptKey crypt, ConfigPropertyOptions options, TryConverter <String, T> converter, IEnumerable <String> sections)
     : base(config, key ?? throw new ArgumentNullException(nameof(key)), crypt, options, sections)
 {
     Config       = config ?? throw new ArgumentNullException(nameof(config));
     DefaultValue = defaultValue;
     Validate     = validate;
     Converter    = converter ?? ConvertUtils.TryConvert;
 }
Пример #3
0
        public override V GetPropertyValue <K, V>(PropertyConfig <K, V> config)
        {
            if (!(config.Key is ILabeledKey))
            {
                return(base.GetPropertyValue(config));
            }

            IPropertyConfig noLabelConfig = AbstractLabeledConfigurationSource.MakeNoLabelConfig(config);

            return((V)GetNoLabelPropertyValue(noLabelConfig));
        }
Пример #4
0
        protected override Tuple <object, IConfigurationSource> DoGetPropertyValue <K, V>(PropertyConfig <K, V> propertyConfig)
        {
            if (propertyConfig == null)
            {
                throw new ArgumentNullException("propertyConfig is null");
            }

            if (!(propertyConfig.Key is ILabeledKey))
            {
                return(base.DoGetPropertyValue(propertyConfig));
            }

            IPropertyConfig noLabelPropertyConfig =
                AbstractLabeledConfigurationSource.MakeNoLabelConfig(propertyConfig);

            for (PropertyLabels propertyLabels = ((ILabeledKey)propertyConfig.Key).Labels;
                 propertyLabels != null; propertyLabels = propertyLabels.Alternative)
            {
                foreach (IConfigurationSource source in SortedSources.Values)
                {
                    if (!(source is ILabeledConfigurationSource) && propertyLabels.Labels.Count != 0)
                    {
                        continue;
                    }

                    V value = default(V);
                    if (propertyLabels.Labels.Count == 0)
                    {
                        value = (V)GetPropertyValue(source, noLabelPropertyConfig);
                    }
                    else
                    {
                        value = (V)GetPropertyValue(source, noLabelPropertyConfig, propertyLabels.Labels);
                    }

                    value = ApplyValueFilter(source, propertyConfig, value);

                    if (!object.Equals(value, default(V)))
                    {
                        return(Tuple.Create <object, IConfigurationSource>(value, source));
                    }
                }
            }

            return(Tuple.Create <object, IConfigurationSource>(propertyConfig.DefaultValue, null));
        }
Пример #5
0
 protected virtual object GetPropertyValue(IPropertyConfig propertyConfig)
 {
     return(_genericGetPropertyValueMethod
            .MakeGenericMethod(propertyConfig.GetType().GetGenericArguments())
            .Invoke(this, new object[] { propertyConfig }));
 }
Пример #6
0
 protected virtual Tuple <object, IConfigurationSource> DoGetPropertyValue(IPropertyConfig propertyConfig)
 {
     return((Tuple <object, IConfigurationSource>)_genericDoGetPropertyValueMethod
            .MakeGenericMethod(propertyConfig.GetType().GetGenericArguments())
            .Invoke(this, new object[] { propertyConfig }));
 }
Пример #7
0
 public SubLocalizationAdapter([NotNull] IPropertyConfig config)
 {
     Config = config ?? throw new ArgumentNullException(nameof(config));
 }