Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IDQuery.cs
Go to the documentation of this file.
1using System.Xml;
3
5
6internal sealed class IDQuery : CacheOutputQuery
7{
9 : base(arg)
10 {
11 }
12
13 private IDQuery(IDQuery other)
14 : base(other)
15 {
16 }
17
18 public override object Evaluate(XPathNodeIterator context)
19 {
20 object obj = base.Evaluate(context);
21 XPathNavigator contextNode = context.Current.Clone();
22 switch (GetXPathType(obj))
23 {
24 case XPathResultType.NodeSet:
25 {
27 while ((xPathNavigator = input.Advance()) != null)
28 {
29 ProcessIds(contextNode, xPathNavigator.Value);
30 }
31 break;
32 }
33 case XPathResultType.String:
34 ProcessIds(contextNode, (string)obj);
35 break;
36 case XPathResultType.Number:
37 ProcessIds(contextNode, StringFunctions.toString((double)obj));
38 break;
39 case XPathResultType.Boolean:
40 ProcessIds(contextNode, StringFunctions.toString((bool)obj));
41 break;
42 case (XPathResultType)4:
43 ProcessIds(contextNode, ((XPathNavigator)obj).Value);
44 break;
45 }
46 return this;
47 }
48
49 private void ProcessIds(XPathNavigator contextNode, string val)
50 {
51 string[] array = XmlConvert.SplitString(val);
52 for (int i = 0; i < array.Length; i++)
53 {
54 if (contextNode.MoveToId(array[i]))
55 {
56 Query.Insert(outputBuffer, contextNode);
57 }
58 }
59 }
60
61 public override XPathNavigator MatchNode(XPathNavigator context)
62 {
63 Evaluate(new XPathSingletonIterator(context, moved: true));
65 while ((xPathNavigator = Advance()) != null)
66 {
67 if (xPathNavigator.IsSamePosition(context))
68 {
69 return context;
70 }
71 }
72 return null;
73 }
74
75 public override XPathNodeIterator Clone()
76 {
77 return new IDQuery(this);
78 }
79}
override XPathNavigator MatchNode(XPathNavigator context)
Definition IDQuery.cs:61
override object Evaluate(XPathNodeIterator context)
Definition IDQuery.cs:18
void ProcessIds(XPathNavigator contextNode, string val)
Definition IDQuery.cs:49
override XPathNodeIterator Clone()
Definition IDQuery.cs:75
XPathResultType GetXPathType(object value)
Definition Query.cs:147
XPathNavigator Advance()
static bool Insert(List< XPathNavigator > buffer, XPathNavigator nav)
Definition Query.cs:87
static string toString(double num)
static string[] SplitString(string value)