Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Query.cs
Go to the documentation of this file.
1using System;
5using System.Xml;
8
10
11[DebuggerDisplay("{ToString()}")]
12internal abstract class Query : ResetableIterator
13{
14 public override int Count
15 {
16 get
17 {
18 if (count == -1)
19 {
21 query.Reset();
22 count = 0;
23 while (query.MoveNext())
24 {
25 count++;
26 }
27 }
28 return count;
29 }
30 }
31
32 public virtual double XsltDefaultPriority => 0.5;
33
34 public abstract XPathResultType StaticType { get; }
35
36 public virtual QueryProps Properties => QueryProps.Merge;
37
38 public Query()
39 {
40 }
41
42 protected Query(Query other)
43 : base(other)
44 {
45 }
46
47 public override bool MoveNext()
48 {
49 return Advance() != null;
50 }
51
52 public virtual void SetXsltContext(XsltContext context)
53 {
54 }
55
56 public abstract object Evaluate(XPathNodeIterator nodeIterator);
57
58 public abstract XPathNavigator Advance();
59
64
65 [return: NotNullIfNotNull("input")]
66 public static Query Clone(Query input)
67 {
68 if (input != null)
69 {
70 return (Query)input.Clone();
71 }
72 return null;
73 }
74
75 [return: NotNullIfNotNull("input")]
77 {
78 return input?.Clone();
79 }
80
81 [return: NotNullIfNotNull("input")]
83 {
84 return input?.Clone();
85 }
86
88 {
89 int num = 0;
90 int num2 = buffer.Count;
91 if (num2 != 0)
92 {
93 switch (CompareNodes(buffer[num2 - 1], nav))
94 {
95 case XmlNodeOrder.Same:
96 return false;
97 case XmlNodeOrder.Before:
98 buffer.Add(nav.Clone());
99 return true;
100 }
101 num2--;
102 }
103 while (num < num2)
104 {
105 int median = GetMedian(num, num2);
106 switch (CompareNodes(buffer[median], nav))
107 {
108 case XmlNodeOrder.Same:
109 return false;
110 case XmlNodeOrder.Before:
111 num = median + 1;
112 break;
113 default:
114 num2 = median;
115 break;
116 }
117 }
118 buffer.Insert(num, nav.Clone());
119 return true;
120 }
121
122 private static int GetMedian(int l, int r)
123 {
124 return l + r >>> 1;
125 }
126
128 {
129 XmlNodeOrder xmlNodeOrder = l.ComparePosition(r);
130 if (xmlNodeOrder == XmlNodeOrder.Unknown)
131 {
133 xPathNavigator.MoveToRoot();
134 string baseURI = xPathNavigator.BaseURI;
135 if (!xPathNavigator.MoveTo(r))
136 {
137 xPathNavigator = r.Clone();
138 }
139 xPathNavigator.MoveToRoot();
140 string baseURI2 = xPathNavigator.BaseURI;
141 int num = string.CompareOrdinal(baseURI, baseURI2);
142 xmlNodeOrder = ((num >= 0) ? ((num > 0) ? XmlNodeOrder.After : XmlNodeOrder.Unknown) : XmlNodeOrder.Before);
143 }
144 return xmlNodeOrder;
145 }
146
148 {
150 {
151 return XPathResultType.NodeSet;
152 }
153 if (value is string)
154 {
155 return XPathResultType.String;
156 }
157 if (value is double)
158 {
159 return XPathResultType.Number;
160 }
161 if (value is bool)
162 {
163 return XPathResultType.Boolean;
164 }
165 return (XPathResultType)4;
166 }
167}
object Evaluate(XPathNodeIterator nodeIterator)
XPathResultType GetXPathType(object value)
Definition Query.cs:147
virtual void SetXsltContext(XsltContext context)
Definition Query.cs:52
virtual QueryProps Properties
Definition Query.cs:36
override bool MoveNext()
Definition Query.cs:47
static XPathNodeIterator Clone(XPathNodeIterator input)
Definition Query.cs:76
virtual XPathNavigator MatchNode(XPathNavigator current)
Definition Query.cs:60
static XmlNodeOrder CompareNodes(XPathNavigator l, XPathNavigator r)
Definition Query.cs:127
XPathNavigator Advance()
virtual double XsltDefaultPriority
Definition Query.cs:32
static bool Insert(List< XPathNavigator > buffer, XPathNavigator nav)
Definition Query.cs:87
XPathResultType StaticType
Definition Query.cs:34
static Query Clone(Query input)
Definition Query.cs:66
static int GetMedian(int l, int r)
Definition Query.cs:122
static XPathNavigator Clone(XPathNavigator input)
Definition Query.cs:82
static string Xp_InvalidPattern
Definition SR.cs:1248
Definition SR.cs:7
static XPathException Create(string res)