/// <summary> /// 解析i18n /// </summary> private void parseI18NXml(string xmlFile) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlFile); XmlNodeList refXmlLst = xmlDoc.SelectNodes("i18n/refs"); XmlNode refsXmlList = refXmlLst[0]; foreach (XmlNode refNode in refsXmlList.ChildNodes) { if (refNode.GetType() == typeof(XmlComment)) { continue; } RefsVo rv = new RefsVo(); rv.id = refNode.Attributes["id"].Value; rv.val = refNode.Attributes["val"].Value; _i18nConfigVo.buildRefsVo(rv); } XmlNodeList itemsXmlLst = xmlDoc.SelectNodes("i18n/items"); XmlNode itemsXmlList = itemsXmlLst[0]; foreach (XmlNode itemNode in itemsXmlList.ChildNodes) { // 如果是注释 continue if (itemNode.GetType() == typeof(XmlComment)) { continue; } I18NItemVo item = new I18NItemVo(); item.key = itemNode.Attributes["key"].Value; if (itemNode.Attributes["val"] != null) { item.val = itemNode.Attributes["val"].Value; } else { item.val = itemNode.InnerText.Trim(); } //if ( string.IsNullOrEmpty( item.val ) ) // throw new Exception( "I18N中 " + item.key + "对应的Val没有填写"); string refs = itemNode.Attributes["refs"] != null ? itemNode.Attributes["refs"].Value : null; if (!string.IsNullOrEmpty(refs)) { item.refArr = refs.Split(new char[] { ',' }); } _i18nConfigVo.buildItemVo(item); } }
public void buildRefsVo(RefsVo rv) { if (_refMapping.ContainsKey(rv.id)) { throw new Exception(" _refMapping.ContainsKey " + rv.id); } _refMapping[rv.id] = rv; }