public static T GetAppSetting <T>(AppSettingKey key, object defaultValue = null) { var asr = new AppSettingsReader(); var value = asr.GetValue(key.ToString(), typeof(T)); if (value == null) { return((T)defaultValue); } return((T)value); }
public MockAppSettingsBuilder WithSetting(AppSettingKey appSettingKey, string value) { Mock.Setup(x => x.GetSetting(appSettingKey)) .Returns(value); return(this); }
public static string GetAppSettingValue(AppSettingKey keyIn) { using (CmsEntities cee = new CmsEntities()) { string keyInText = keyIn.ToString(); return (from x in cee.AppSettings where String.Compare(keyInText, x.Key, StringComparison.OrdinalIgnoreCase) == 0 select x.Value).FirstOrDefault(); } }
public static bool GetAppSettingValue(AppSettingKey keyIn, bool defaultValue) { using (CmsEntities cee = new CmsEntities()) { string keyInText = keyIn.ToString(); var retVal = (from x in cee.AppSettings where String.Compare(keyInText, x.Key, StringComparison.OrdinalIgnoreCase) == 0 select x.Value).FirstOrDefault(); if (String.IsNullOrEmpty(retVal)) { return defaultValue; } retVal = retVal.Trim().ToLower(); if (retVal == "true" || retVal == "t" || retVal == "yes" || retVal == "y") { return true; } return false; } }
public string GetSetting(AppSettingKey key) { return(ConfigurationManager.AppSettings.Get(key.ToString())); }