/// <summary> /// 从 Xml 对象中读取农历节日的定义 /// </summary> /// <returns></returns> private static xList <OB> getLunarFeasts() { const string xPath = "SharpSxwnl/SxwnlData/Data[@Id = 'obb_getDayName']"; xList <OB> result = new xList <OB>(); if (LunarHelper.SxwnlXmlData != null) { XmlNodeList foundNodeList = LunarHelper.SxwnlXmlData.SelectNodes(xPath); if (foundNodeList.Count > 0) { for (int i = 0; i < foundNodeList.Count; i++) { for (int j = 0; j < foundNodeList[i].ChildNodes.Count; j++) { result.Add(new OB()); // 添加日对象来记录节点信息 XmlAttributeCollection xmlAttr = foundNodeList[i].ChildNodes[j].Attributes; result[result.Count - 1].Lmc = xmlAttr.GetNamedItem("Day").InnerText; result[result.Count - 1].A = xmlAttr.GetNamedItem("A").InnerText; result[result.Count - 1].B = xmlAttr.GetNamedItem("B").InnerText; result[result.Count - 1].C = xmlAttr.GetNamedItem("C").InnerText; result[result.Count - 1].Fjia = LunarHelper.VAL(xmlAttr.GetNamedItem("Fjia").InnerText) == 0 ? 0 : 1; } } } } return(result); }
private static xList <xList <string> > __sFtv = oba.getsFtvData(); // 国历节日,#表示放假日,I表示重要节日或纪念日 #endregion #region 转换时新增的方法 /// <summary> /// 从 Xml 文档对象加载 wFtv 数据 /// </summary> /// <returns></returns> private static xList <string> getwFtvData() { xList <string> result = new xList <string>(); //---------------------------------------------------------------------------------------- // 加载 Xml 数据: 按周规则定义的节日(纪念日) // 注: 加载时自动去除各行 Xml 数据前、后端的所有空白字符, 但对数据内部的空白字符不作处理 //---------------------------------------------------------------------------------------- if (LunarHelper.SxwnlXmlData != null) { const string wFtvXPath = "SharpSxwnl/SxwnlData/Data[@Id = 'oba_wFtv']"; XmlNode foundNode; Regex regexToTrim = new Regex(@"(^\s*)|(\s*$)"); // C#: 匹配任何空白字符 // 读取并解开数据 foundNode = LunarHelper.SxwnlXmlData.SelectSingleNode(wFtvXPath); if (foundNode != null) { string[] wftv = regexToTrim.Replace(foundNode.InnerText, "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < wftv.Length; i++) { result.Add(regexToTrim.Replace(wftv[i], "")); } } } return(result); }
/// <summary> /// 从 Xml 对象中读取农历节日的定义 /// </summary> /// <returns></returns> private static xList <string> getJieQiFeasts() { const string xPath = "SharpSxwnl/SxwnlData/Data[@Id = 'obb_JieqiFjia']"; xList <string> result = new xList <string>(); if (LunarHelper.SxwnlXmlData != null) { XmlNode foundNode; Regex regexToTrim = new Regex(@"\s*"); // C#: 匹配任何空白字符, 用于去除所有空白字符 // 读取并解开历史纪年表 foundNode = LunarHelper.SxwnlXmlData.SelectSingleNode(xPath); if (foundNode != null) { string[] jieqiFeasts = regexToTrim.Replace(foundNode.InnerText, "").Split(','); result.AddRange(jieqiFeasts); } } return(result); }
/// <summary> /// 从 Xml 文档对象加载 sFtv 数据 /// </summary> /// <returns></returns> private static xList <xList <string> > getsFtvData() { const int monthNumPerYear = 12; xList <xList <string> > result = new xList <xList <string> >(); for (int i = 0; i < monthNumPerYear; i++) // C#: 预置 12 个元素 { result.Add(new xList <string>()); } //---------------------------------------------------------------------------------------- // 加载 Xml 数据: 按周规则定义的节日(纪念日) // 注: 加载时自动去除各行 Xml 数据前、后端的所有空白字符, 但对数据内部的空白字符不作处理 //---------------------------------------------------------------------------------------- if (LunarHelper.SxwnlXmlData != null) { XmlNode foundNode; Regex regexToTrim = new Regex(@"(^\s*)|(\s*$)"); // C#: 匹配前、后端的任何空白字符 for (int i = 0; i < monthNumPerYear; i++) { string xPath = "SharpSxwnl/SxwnlData/Data[@Id = 'oba_sFtv']/Month[@Id = '" + (i + 1).ToString() + "']"; foundNode = LunarHelper.SxwnlXmlData.SelectSingleNode(xPath); if (foundNode != null) { string[] sftv = regexToTrim.Replace(foundNode.InnerText, "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < sftv.Length; j++) { result[i].Add(regexToTrim.Replace(sftv[j], "")); } } } } return(result); }