/// <summary> /// 获取所有本地化业务参数配置 /// </summary> /// <param name="GroupType">配置项大类</param> /// <param name="Key">配置项小类</param> /// <returns>指定配置项</returns> public static Options GetLocalOptionsByKey(string GroupType, string Key) { string localPath = ConfigInit.GetLocalConfigPath(); if (File.Exists(localPath)) { XmlDocument doc = new XmlDocument(); doc.Load(localPath); string xmlPath = "//CustomLocalParams/BusinessParams[@key='" + GroupType + "']/param[@key='" + Key + "']"; var node = doc.SelectSingleNode(xmlPath); if (node != null) { Options op = null; XmlAttribute attr = null; attr = node.Attributes["key"]; string key = attr != null ? attr.Value : string.Empty; if (!string.IsNullOrEmpty(key)) { op = new Options(); op.Key = key; op.Value = node.InnerText; } return(op); } } return(null); }
/// <summary> /// 获取所有本地化业务参数配置 /// </summary> /// <param name="GroupType">配置项大类</param> /// <returns>所有配置项</returns> public static List <Options> GetLocalOptions(string GroupType) { string localPath = ConfigInit.GetLocalConfigPath(); if (File.Exists(localPath)) { XmlDocument doc = new XmlDocument(); doc.Load(localPath); string xmlPath = "//CustomLocalParams/BusinessParams"; if (!string.IsNullOrEmpty(GroupType)) { xmlPath += "[@key='" + GroupType + "']"; } var nodes = doc.SelectNodes(xmlPath); if (nodes != null) { List <Options> list = new List <Options>(); Options op = null; XmlAttribute attr = null; foreach (XmlNode node in nodes) { attr = node.Attributes["key"]; string OptionType = attr != null ? attr.Value : string.Empty; var childNodes = node.ChildNodes; if (childNodes != null) { foreach (XmlNode childNode in childNodes) { if (childNode.Attributes == null) { continue; } attr = childNode.Attributes["key"]; string key = attr != null ? attr.Value : string.Empty; if (!string.IsNullOrEmpty(key)) { op = new Options(); op.OptionType = OptionType; op.Key = key; op.Value = childNode.InnerText; list.Add(op); } } } } return(list); } } return(new List <Options>()); }