Ejemplo n.º 1
0
        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);
 }
Ejemplo n.º 3
0
 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();
     }
 }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
 public string GetSetting(AppSettingKey key)
 {
     return(ConfigurationManager.AppSettings.Get(key.ToString()));
 }