Пример #1
0
        /// <summary>
        /// Getting an effective (the most relevant) setting value.
        /// </summary>
        /// <remarks>
        /// This method observes all sources starting from the last one (which has highest priority)
        /// till a source returns a not-null value for given key.
        /// </remarks>
        /// <param name="key">The setting key</param>
        /// <param name="scope">The scope for searching a setting value. "User" indicates that
        /// all sources are observed; "Application" means that only "Application" sources are observed.
        /// Default value is "User".
        /// </param>
        /// <returns>The effective setting value or null if none of sources contains given key.</returns>
        public string GetEffectiveValue(string key, SettingScopeEnum scope = SettingScopeEnum.User)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            if (EffectiveScope < scope)
            {
                scope = EffectiveScope;
            }

            for (int i = Sources.Count - 1; i >= 0; i--)
            {
                var source = Sources[i];
                if (scope < source.Scope)
                {
                    continue;
                }

                var value = source.GetValue(key);
                if (value != null)
                {
                    return(value);
                }
            }

            return(null);
        }
Пример #2
0
        public BaseSettingDefinition(string name, string description, T defaultValue, SettingScopeEnum scope)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            Name         = name;
            Description  = description;
            DefaultValue = ConvertToString(defaultValue);
            Scope        = scope;
        }
Пример #3
0
 public StringSettingDefinition(string name, string description, string value = null, SettingScopeEnum scope = SettingScopeEnum.User)
     : base(name, description, value ?? String.Empty, scope)
 {
 }
Пример #4
0
 public BoolSettingDefinition(string name, string description, bool value, SettingScopeEnum scope = SettingScopeEnum.User)
     : base(name, description, value, scope)
 {
 }
Пример #5
0
 public IntegerSettingDefinition(string name, string description, int value, SettingScopeEnum scope = SettingScopeEnum.User)
     : base(name, description, value, scope)
 {
 }
Пример #6
0
 public TimeZoneSettingDefinition(string name, string description, TimeZoneInfo value, SettingScopeEnum scope = SettingScopeEnum.User)
     : base(name, description, value, scope)
 {
 }
Пример #7
0
 public EncodingSettingDefinition(string name, string description, Encoding value, SettingScopeEnum scope = SettingScopeEnum.User)
     : base(name, description, value, scope)
 {
 }
 public TestBaseSettingDefinition(string name, string description, int defaultValue, SettingScopeEnum scope)
     : base(name, description, defaultValue, scope)
 {
 }