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); }
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); }
public static String Read(ConfigKeys key) { String value = ConfigurationManager.AppSettings[Enum.GetName(key.GetType(), key)]; return((!String.IsNullOrEmpty(value)) ? value.Trim() : String.Empty); }