public string GetApplicationSettingByKey(ApplicationSettingKey key)
        {
            var keyAsString = key.ToString();

            try
            {
                var settings = Context.ApplicationSettings.FirstOrDefault((ask) => ask.ConfigurationKey == keyAsString);
                if (settings != null)
                {
                    if (!string.IsNullOrEmpty(settings.ConfigurationValue))
                    {
                        return(settings.ConfigurationValue);
                    }
                    return(settings.DefaultValue);
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public void UpdateSetting(ApplicationSettingKey key, string value)
        {
            var stringKey = key.ToString();

            UpdateSettingValue(stringKey, value);
        }
Beispiel #3
0
 /// <summary>
 /// Gets Value for Key from App.Config. Returns null if key does not exist.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static string GetFromApplicationSetting(ApplicationSettingKey key)
 {
     return(ConfigurationManager.AppSettings.Get(key.ToString()));
 }