Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NodeFunctions.cs
Go to the documentation of this file.
3
5
6internal sealed class NodeFunctions : ValueQuery
7{
8 private readonly Query _arg;
9
11
13
15
17 {
18 _funcType = funcType;
19 _arg = arg;
20 }
21
22 public override void SetXsltContext(XsltContext context)
23 {
24 _xsltContext = (context.Whitespace ? context : null);
25 if (_arg != null)
26 {
27 _arg.SetXsltContext(context);
28 }
29 }
30
32 {
33 if (_arg == null)
34 {
35 return context.Current;
36 }
37 _arg.Evaluate(context);
38 return _arg.Advance();
39 }
40
41 public override object Evaluate(XPathNodeIterator context)
42 {
43 switch (_funcType)
44 {
45 case Function.FunctionType.FuncPosition:
46 return (double)context.CurrentPosition;
47 case Function.FunctionType.FuncLast:
48 return (double)context.Count;
49 case Function.FunctionType.FuncNameSpaceUri:
50 {
51 XPathNavigator xPathNavigator2 = EvaluateArg(context);
52 if (xPathNavigator2 != null)
53 {
54 return xPathNavigator2.NamespaceURI;
55 }
56 break;
57 }
58 case Function.FunctionType.FuncLocalName:
59 {
60 XPathNavigator xPathNavigator2 = EvaluateArg(context);
61 if (xPathNavigator2 != null)
62 {
63 return xPathNavigator2.LocalName;
64 }
65 break;
66 }
67 case Function.FunctionType.FuncName:
68 {
69 XPathNavigator xPathNavigator2 = EvaluateArg(context);
70 if (xPathNavigator2 != null)
71 {
72 return xPathNavigator2.Name;
73 }
74 break;
75 }
76 case Function.FunctionType.FuncCount:
77 {
78 _arg.Evaluate(context);
79 int num = 0;
80 if (_xsltContext != null)
81 {
82 XPathNavigator xPathNavigator;
83 while ((xPathNavigator = _arg.Advance()) != null)
84 {
85 if (xPathNavigator.NodeType != XPathNodeType.Whitespace || _xsltContext.PreserveWhitespace(xPathNavigator))
86 {
87 num++;
88 }
89 }
90 }
91 else
92 {
93 while (_arg.Advance() != null)
94 {
95 num++;
96 }
97 }
98 return (double)num;
99 }
100 }
101 return string.Empty;
102 }
103
104 public override XPathNodeIterator Clone()
105 {
106 NodeFunctions nodeFunctions = new NodeFunctions(_funcType, Query.Clone(_arg));
107 nodeFunctions._xsltContext = _xsltContext;
108 return nodeFunctions;
109 }
110}
static XPathResultType[] ReturnTypes
Definition Function.cs:48
override XPathResultType StaticType
XPathNavigator EvaluateArg(XPathNodeIterator context)
readonly Function.FunctionType _funcType
override void SetXsltContext(XsltContext context)
override object Evaluate(XPathNodeIterator context)
override XPathNodeIterator Clone()
NodeFunctions(Function.FunctionType funcType, Query arg)
object Evaluate(XPathNodeIterator nodeIterator)
virtual void SetXsltContext(XsltContext context)
Definition Query.cs:52
XPathNavigator Advance()
static Query Clone(Query input)
Definition Query.cs:66
bool PreserveWhitespace(XPathNavigator node)