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 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 Read(ConfigKeys property) { try { return(ConfigurationManager.AppSettings[property.ToString()]); } catch (Exception) { return(null); } }
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); }
public string GetValue(ConfigKeys key) { return(GetValue(key.ToString())); }