Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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));
        }