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']"; XElement foundNode; Regex regexToTrim = new Regex(@"(^\s*)|(\s*$)"); // C#: 匹配任何空白字符 // 读取并解开数据 foundNode = LunarHelper.GetXmlNode("oba_wFtv"); if (foundNode != null) { string[] wftv = regexToTrim.Replace(foundNode.Value, "").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 <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); XElement node = LunarHelper.GetXmlNode("obb_getDayName"); if (node != null) { foreach (XElement child in node.Elements()) { result.Add(new OB()); // 添加日对象来记录节点信息 result[result.Count - 1].Lmc = child.Attribute("Day").Value; result[result.Count - 1].A = child.Attribute("A").Value; result[result.Count - 1].B = child.Attribute("B").Value; result[result.Count - 1].C = child.Attribute("C").Value; result[result.Count - 1].Fjia = LunarHelper.VAL(child.Attribute("Fjia").Value) == 0 ? 0 : 1; } } } 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) { XElement 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.GetXmlNode("oba_sFtv"); XElement month = foundNode?.Elements().FirstOrDefault(m => m.Attribute("Id").Value == (i + 1).ToString()); if (month != null) { string[] sftv = regexToTrim.Replace(month.Value, "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < sftv.Length; j++) { result[i].Add(regexToTrim.Replace(sftv[j], "")); } } } } return(result); }