Example #1
0
 public static string GetSection(this ConfigKeys val)
 {
     Section[] attributes = (Section[])val
                            .GetType()
                            .GetField(val.ToString())
                            .GetCustomAttributes(typeof(Section), false);
     return(attributes.Length > 0 ? attributes[0].Name : null);
 }
Example #2
0
 public static string GetName(this ConfigKeys val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val
                                         .GetType()
                                         .GetField(val.ToString())
                                         .GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }
Example #3
0
 public static string Read(ConfigKeys property)
 {
     try
     {
         return(ConfigurationManager.AppSettings[property.ToString()]);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #4
0
 public static string Read(ConfigKeys property)
 {
     try
     {
         return ConfigurationManager.AppSettings[property.ToString()];
     }
     catch (Exception)
     {
         return null;
     }
 }
        /// <summary>
        /// 按key获取一个配置项
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        private ConfigItem GetItem(ConfigKeys key)
        {
            ConfigItem item;

            if (configItems.TryGetValue(key, out item))
            {
                return(item);
            }
            else
            {
                throw new ConfigManagerException("[ConfigManager.GetItem] Cannot find config with key: " + key.ToString());
            }
        }
        public static string GetValue(ConfigKeys key)
        {
            var path = ConfigurationManager.AppSettings[key.ToString()];

            return(path);
        }
Example #7
0
 public string GetValue(ConfigKeys key)
 {
     return(GetValue(key.ToString()));
 }