当前位置: 首页>>代码示例>>C#>>正文


C# XPathDocument.Compile方法代码示例

本文整理汇总了C#中System.Xml.XPath.XPathDocument.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# XPathDocument.Compile方法的具体用法?C# XPathDocument.Compile怎么用?C# XPathDocument.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XPath.XPathDocument的用法示例。


在下文中一共展示了XPathDocument.Compile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMessageStructure

 internal static ArrayList GetMessageStructure(string inputMsgFile, CommunicationManager.ReceiverType RxType, int mid, int sid, string protocol, string version)
 {
     XPathNavigator navigator = new XPathDocument(inputMsgFile).CreateNavigator();
     int num = 2;
     int num2 = 2;
     int num3 = 0;
     if (RxType == CommunicationManager.ReceiverType.SLC)
     {
         num3 = 1;
     }
     ArrayList list = new ArrayList();
     SLCMsgStructure structure = new SLCMsgStructure();
     int num4 = 0;
     XPathExpression expr = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '", sid, "']/field" }));
     XPathNodeIterator iterator = navigator.Select(expr);
     if (iterator.Count == 0)
     {
         expr = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '']/field" }));
         iterator = navigator.Select(expr);
     }
     try
     {
         int num5 = 0;
         int num6 = 0;
         while (iterator.MoveNext())
         {
             XPathNavigator navigator2 = iterator.Current.Clone();
             if (navigator2.GetAttribute("name", "").Contains("LOOP"))
             {
                 num5 = int.Parse(navigator2.GetAttribute("numloops", ""));
                 num6 = int.Parse(navigator2.GetAttribute("numlines", ""));
                 for (int i = 0; i < num5; i++)
                 {
                     for (int j = 0; j < num6; j++)
                     {
                         iterator.MoveNext();
                         navigator2 = iterator.Current.Clone();
                         structure.fieldNumber = iterator.CurrentPosition;
                         structure.fieldName = navigator2.GetAttribute("name", "");
                         structure.bytes = int.Parse(navigator2.GetAttribute("bytes", ""));
                         structure.datatype = navigator2.GetAttribute("datatype", "");
                         structure.units = navigator2.GetAttribute("units", "");
                         if (navigator2.GetAttribute("scale", "") == "")
                         {
                             structure.scale = 1.0;
                         }
                         else
                         {
                             structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                         }
                         structure.startByte = (((num + num2) + num3) + 1) + num4;
                         structure.endByte = (structure.startByte + structure.bytes) - 1;
                         structure.defaultValue = navigator2.GetAttribute("default", "");
                         num4 += structure.bytes;
                         list.Add(structure);
                     }
                 }
             }
             else
             {
                 structure.fieldNumber = iterator.CurrentPosition;
                 structure.fieldName = navigator2.GetAttribute("name", "");
                 structure.bytes = int.Parse(navigator2.GetAttribute("bytes", ""));
                 structure.datatype = navigator2.GetAttribute("datatype", "");
                 structure.units = navigator2.GetAttribute("units", "");
                 if (navigator2.GetAttribute("scale", "") == "")
                 {
                     structure.scale = 1.0;
                 }
                 else
                 {
                     structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                 }
                 structure.startByte = (((num + num2) + num3) + 1) + num4;
                 structure.endByte = (structure.startByte + structure.bytes) - 1;
                 structure.defaultValue = navigator2.GetAttribute("default", "");
                 num4 += structure.bytes;
                 list.Add(structure);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return list;
 }
开发者ID:facchinm,项目名称:SiRFLive,代码行数:87,代码来源:utils_AutoReply.cs


注:本文中的System.Xml.XPath.XPathDocument.Compile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。