private string TryGetConfigurationValue(ConfigurationAttribute attribute)
 {
     try
     {
         return(GetConfigurationValue(attribute));
     }
     catch (Exception e)
     {
         if (attribute.DefaultValue == null)
         {
             Log.Error("Unable to read configuration variable [{0}]".ExpandWith(attribute.Name));
             Log.Error(e);
             throw;
         }
         Log.Warning("Unable to read configuration variable [{0}], using default value [{0}]".ExpandWith(attribute.Name, attribute.DefaultValue));
         return(attribute.DefaultValue);
     }
 }
Beispiel #2
0
 private static string GetConfigurationValue(ConfigurationAttribute attribute)
 {
     try
     {
         var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         return(config.AppSettings.Settings[attribute.Name].Value);
     }
     catch (Exception e)
     {
         if (attribute.DefaultValue == null)
         {
             Log.Error("Unable to read configuration variable [{0}]".ExpandWith(attribute.Name));
             Log.Error(e);
             throw;
         }
         Log.Warning("Unable to read configuration variable [{0}], using default value [{0}]".ExpandWith(attribute.Name, attribute.DefaultValue));
         return(attribute.DefaultValue);
     }
 }
 public virtual string GetConfigurationValue(ConfigurationAttribute attribute)
 {
     return(ConfigurationManager.AppSettings[attribute.Name]);
 }