// 获得特定界面语言下的language名称列表 // 找语言的时候,先找精确的,找不到再找模糊的 public List<CaptionValue> GetLanguageCaptionValues(string strLang) { List<CaptionValue> results = new List<CaptionValue>(); XmlNodeList nodes = this.CfgDom.SelectNodes("//languages/item"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; string strLanguageName = DomUtil.GetAttr(node, "name"); string strCaption = DomUtil.GetCaption(strLang, node); CaptionValue pair = null; if (strCaption == null) { // 如果下面根本没有定义<caption>元素,则采用<element>元素的name属性值 if (String.IsNullOrEmpty(strLanguageName) == true) continue; // 实在没有,只好舍弃 pair = new CaptionValue(); pair.Caption = "<" + strLanguageName + ">"; pair.Value = strCaption; results.Add(pair); continue; } pair = new CaptionValue(); pair.Caption = strCaption; pair.Value = strLanguageName; results.Add(pair); } return results; }
/* // 获得特定界面语言下的、特定Element的refinement列表 public List<CaptionValue> GetRefinementCaptionValues(string strLang, string strElementValue) { List<CaptionValue> results = new List<CaptionValue>(); XmlNodeList nodes = this.CfgDom.SelectNodes("//elements/element[@name='"+strElementValue+"']/refinements/refinement"); for (int i = 0; i < nodes.Count; i++) { string strRefinementName = DomUtil.GetAttr(nodes[i], "name"); string strCaption = DomUtil.GetCaption(strLang, nodes[i]); CaptionValue pair = null; if (strCaption == null) { // 如果下面根本没有定义<caption>元素,则采用<refinement>元素的name属性值 if (String.IsNullOrEmpty(strRefinementName) == true) continue; // 实在没有,只好舍弃 pair = new CaptionValue(); pair.Caption = "<" + strRefinementName + ">"; pair.Value = strCaption; results.Add(pair); continue; } pair = new CaptionValue(); pair.Caption = strCaption; pair.Value = strRefinementName; results.Add(pair); } return results; } * */ // 获得特定界面语言下的、特定Element的、特定refinement的type列表 public List<CaptionValue> GetTypeCaptionValues(string strLang, string strElementValue/*, string strRefinementValue*/) { List<CaptionValue> results = new List<CaptionValue>(); string strXPath = ""; strXPath = "//element[@name='" + strElementValue + "']/types/type"; XmlNodeList nodes = this.CfgDom.SelectNodes(strXPath); for (int i = 0; i < nodes.Count; i++) { string strTypeName = DomUtil.GetAttr(nodes[i], "name"); string strCaption = DomUtil.GetCaption(strLang, nodes[i]); CaptionValue pair = null; if (strCaption == null) { // 如果下面根本没有定义<caption>元素,则采用<type>元素的name属性值 if (String.IsNullOrEmpty(strTypeName) == true) continue; // 实在没有,只好舍弃 pair = new CaptionValue(); pair.Caption = "<" + strTypeName + ">"; pair.Value = strCaption; results.Add(pair); continue; } pair = new CaptionValue(); pair.Caption = strCaption; pair.Value = strTypeName; results.Add(pair); } return results; }
// 获得特定界面语言下的Element名称列表 // 找语言的时候,先找精确的,找不到再找模糊的 public List<CaptionValue> GetElementCaptionValues(string strLang) { List<CaptionValue> results = new List<CaptionValue>(); XmlNodeList nodes = this.CfgDom.SelectNodes("//element"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; string strElementName = DomUtil.GetAttr(node, "name"); string strCaption = DomUtil.GetCaption(strLang, node); bool bRefinement = false; if (node.ParentNode.Name == "refinements") bRefinement = true; CaptionValue pair = null; if (strCaption == null) { // 如果下面根本没有定义<caption>元素,则采用<element>元素的name属性值 if (String.IsNullOrEmpty(strElementName) == true) continue; // 实在没有,只好舍弃 pair = new CaptionValue(); pair.Caption = "<" + strElementName + ">"; if (bRefinement == true) pair.Value = " " + strCaption; else pair.Value = strCaption; results.Add(pair); continue; } pair = new CaptionValue(); if (bRefinement == true) pair.Caption = " " + strCaption; else pair.Caption = strCaption; pair.Value = strElementName; results.Add(pair); } return results; }