Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NodeFunctions.cs
Go to the documentation of this file.
1
using
System.Xml.XPath
;
2
using
System.Xml.Xsl
;
3
4
namespace
MS.Internal.Xml.XPath
;
5
6
internal
sealed
class
NodeFunctions
:
ValueQuery
7
{
8
private
readonly
Query
_arg
;
9
10
private
readonly
Function.FunctionType
_funcType
;
11
12
private
XsltContext
_xsltContext
;
13
14
public
override
XPathResultType
StaticType
=>
Function
.
ReturnTypes
[(int)
_funcType
];
15
16
public
NodeFunctions
(
Function
.
FunctionType
funcType,
Query
arg)
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
31
private
XPathNavigator
EvaluateArg
(
XPathNodeIterator
context)
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
}
MS.Internal.Xml.XPath.Function.FunctionType
FunctionType
Definition
Function.cs:9
MS.Internal.Xml.XPath.Function.ReturnTypes
static XPathResultType[] ReturnTypes
Definition
Function.cs:48
MS.Internal.Xml.XPath.Function
Definition
Function.cs:7
MS.Internal.Xml.XPath.NodeFunctions.StaticType
override XPathResultType StaticType
Definition
NodeFunctions.cs:14
MS.Internal.Xml.XPath.NodeFunctions._arg
readonly Query _arg
Definition
NodeFunctions.cs:8
MS.Internal.Xml.XPath.NodeFunctions.EvaluateArg
XPathNavigator EvaluateArg(XPathNodeIterator context)
Definition
NodeFunctions.cs:31
MS.Internal.Xml.XPath.NodeFunctions._funcType
readonly Function.FunctionType _funcType
Definition
NodeFunctions.cs:10
MS.Internal.Xml.XPath.NodeFunctions.SetXsltContext
override void SetXsltContext(XsltContext context)
Definition
NodeFunctions.cs:22
MS.Internal.Xml.XPath.NodeFunctions._xsltContext
XsltContext _xsltContext
Definition
NodeFunctions.cs:12
MS.Internal.Xml.XPath.NodeFunctions.Evaluate
override object Evaluate(XPathNodeIterator context)
Definition
NodeFunctions.cs:41
MS.Internal.Xml.XPath.NodeFunctions.Clone
override XPathNodeIterator Clone()
Definition
NodeFunctions.cs:104
MS.Internal.Xml.XPath.NodeFunctions.NodeFunctions
NodeFunctions(Function.FunctionType funcType, Query arg)
Definition
NodeFunctions.cs:16
MS.Internal.Xml.XPath.NodeFunctions
Definition
NodeFunctions.cs:7
MS.Internal.Xml.XPath.Query.Evaluate
object Evaluate(XPathNodeIterator nodeIterator)
MS.Internal.Xml.XPath.Query.SetXsltContext
virtual void SetXsltContext(XsltContext context)
Definition
Query.cs:52
MS.Internal.Xml.XPath.Query.Advance
XPathNavigator Advance()
MS.Internal.Xml.XPath.Query.Clone
static Query Clone(Query input)
Definition
Query.cs:66
MS.Internal.Xml.XPath.Query
Definition
Query.cs:13
MS.Internal.Xml.XPath.ValueQuery
Definition
ValueQuery.cs:7
System.Xml.XPath.XPathNavigator.LocalName
string LocalName
Definition
XPathNavigator.cs:390
System.Xml.XPath.XPathNavigator.NodeType
XPathNodeType NodeType
Definition
XPathNavigator.cs:388
System.Xml.XPath.XPathNavigator.NamespaceURI
string NamespaceURI
Definition
XPathNavigator.cs:394
System.Xml.XPath.XPathNavigator.Name
string Name
Definition
XPathNavigator.cs:392
System.Xml.XPath.XPathNavigator
Definition
XPathNavigator.cs:15
System.Xml.XPath.XPathNodeIterator.Count
virtual int Count
Definition
XPathNodeIterator.cs:66
System.Xml.XPath.XPathNodeIterator.CurrentPosition
int CurrentPosition
Definition
XPathNodeIterator.cs:63
System.Xml.XPath.XPathNodeIterator.Current
XPathNavigator? Current
Definition
XPathNodeIterator.cs:61
System.Xml.XPath.XPathNodeIterator
Definition
XPathNodeIterator.cs:8
System.Xml.Xsl.XsltContext.PreserveWhitespace
bool PreserveWhitespace(XPathNavigator node)
System.Xml.Xsl.XsltContext
Definition
XsltContext.cs:6
MS.Internal.Xml.XPath
Definition
AbsoluteQuery.cs:3
System.Xml.XPath.XPathResultType
XPathResultType
Definition
XPathResultType.cs:4
System.Xml.XPath.XPathNodeType
XPathNodeType
Definition
XPathNodeType.cs:4
System.Xml.XPath
Definition
Extensions.cs:5
System.Xml.Xsl
Definition
BranchingContext.cs:1
source
System.Private.Xml
MS.Internal.Xml.XPath
NodeFunctions.cs
Generated by
1.10.0