本文整理汇总了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;
}