/// <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); }
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; }
public StringSettingDefinition(string name, string description, string value = null, SettingScopeEnum scope = SettingScopeEnum.User) : base(name, description, value ?? String.Empty, scope) { }
public BoolSettingDefinition(string name, string description, bool value, SettingScopeEnum scope = SettingScopeEnum.User) : base(name, description, value, scope) { }
public IntegerSettingDefinition(string name, string description, int value, SettingScopeEnum scope = SettingScopeEnum.User) : base(name, description, value, scope) { }
public TimeZoneSettingDefinition(string name, string description, TimeZoneInfo value, SettingScopeEnum scope = SettingScopeEnum.User) : base(name, description, value, scope) { }
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) { }