示例#1
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);
 }
示例#2
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);
 }
示例#3
0
        public static String Read(ConfigKeys key)
        {
            String value = ConfigurationManager.AppSettings[Enum.GetName(key.GetType(), key)];

            return((!String.IsNullOrEmpty(value)) ? value.Trim() : String.Empty);
        }