public T GetSetting <T>(SettingEntryKey key) { Throw.IfArgumentNull(key, nameof(key)); Throw.IfNot(TryGetSetting(key, out T value)) .AnArgumentException("No provider has a setting entry named '{0}' in category '{1}'.".FormatWith(key.Name, key.Category), nameof(key)); return(value); }
public virtual bool TrySetSetting <T>(SettingEntryKey key, T value) { Throw.IfArgumentNull(key, nameof(key)); var provider = (IWritableSettingsProvider)_settingsProviders.FirstOrDefault(p => p.SettingExists(key) && p is IWritableSettingsProvider); return(provider != null && provider.TrySetSetting(key, value)); }
public virtual bool TryGetSetting <T>(SettingEntryKey key, out T value) { Throw.IfArgumentNull(key, nameof(key)); var provider = _settingsProviders.FirstOrDefault(p => p.SettingExists(key)); value = default(T); return(provider != null && provider.TryGetSetting(key, out value)); }
public bool Equals(SettingEntryKey other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.Category.EqualsIgnoreCase(Category) && other.Name.EqualsIgnoreCase(Name)); }
public void SetSetting <T>(SettingEntryKey key, T value) { Throw.IfArgumentNull(key, nameof(key)); Throw.IfNot(TrySetSetting(key, value)) .AnArgumentException("No writable provider has a setting entry named '{0}' in category '{1}'.".FormatWith(key.Name, key.Category), nameof(key)); }
public virtual bool SettingExists(SettingEntryKey key) { return(_settingsProviders.Any(p => p.SettingExists(key))); }