Exemple #1
0
 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);
 }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 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));
 }
Exemple #5
0
 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));
 }
Exemple #6
0
 public virtual bool SettingExists(SettingEntryKey key)
 {
     return(_settingsProviders.Any(p => p.SettingExists(key)));
 }