public string Get(string key, string defaultValue) { try { _lock.EnterReadLock(); if (!__readOnlySettings.ContainsKey(key)) { return(defaultValue); } return(Get(key)); } finally { _lock.ExitReadLock(); } }
public T Get <T> (string key) { try { _lock.EnterReadLock(); ValidateSettingsAreLoaded(); ISettingsList settings = _readOnlySettings; if (!settings.ContainsKey(key)) { throw new KeyNotFoundException(String.Format("Key \"{0}\" was not found", key)); } return((T)settings [key].Value); } finally { _lock.ExitReadLock(); } }
public string Get(string key) { try { _lock.EnterReadLock(); ValidateSettingsAreLoaded(); // todo: add a helper method ISettingsList settings = __readOnlySettings; if (!settings.ContainsKey(key)) { throw new KeyNotFoundException(String.Format("Key \"{0}\" was not found", key)); } Setting result = settings [key]; return((result.Value == null) ? string.Empty : result.Value.ToString()); } finally { _lock.ExitReadLock(); } }