Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FunctionQuery.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.Collections.Generic
;
3
using
System.Xml.XPath
;
4
using
System.Xml.Xsl
;
5
6
namespace
MS.Internal.Xml.XPath
;
7
8
internal
sealed
class
FunctionQuery
:
ExtensionQuery
9
{
10
private
readonly
IList<Query>
_args
;
11
12
private
IXsltContextFunction
_function
;
13
14
public
override
XPathResultType
StaticType
15
{
16
get
17
{
18
XPathResultType
xPathResultType
= ((
_function
!=
null
) ?
_function
.
ReturnType
:
XPathResultType
.Any);
19
if
(
xPathResultType
==
XPathResultType
.Error)
20
{
21
xPathResultType
=
XPathResultType
.Any;
22
}
23
return
xPathResultType
;
24
}
25
}
26
27
public
FunctionQuery
(
string
prefix
,
string
name
,
List<Query>
args
)
28
:
base
(
prefix
,
name
)
29
{
30
_args
=
args
;
31
}
32
33
private
FunctionQuery
(
FunctionQuery
other
)
34
:
base
(
other
)
35
{
36
_function
=
other
._function;
37
Query
[]
array
=
new
Query
[
other
._args.Count];
38
for
(
int
i = 0; i <
array
.Length; i++)
39
{
40
array
[i] =
Query
.
Clone
(
other
._args[i]);
41
}
42
_args
=
array
;
43
_args
=
array
;
44
}
45
46
public
override
void
SetXsltContext
(
XsltContext
context)
47
{
48
if
(context ==
null
)
49
{
50
throw
XPathException
.
Create
(
System
.
SR
.
Xp_NoContext
);
51
}
52
if
(
xsltContext
== context)
53
{
54
return
;
55
}
56
xsltContext
= context;
57
foreach
(
Query
arg
in
_args
)
58
{
59
arg
.SetXsltContext(context);
60
}
61
XPathResultType
[]
array
=
new
XPathResultType
[
_args
.
Count
];
62
for
(
int
i = 0; i <
_args
.
Count
; i++)
63
{
64
array
[i] =
_args
[i].StaticType;
65
}
66
_function
=
xsltContext
.
ResolveFunction
(
prefix
,
name
,
array
);
67
if
(
_function
==
null
)
68
{
69
throw
XPathException
.
Create
(
System
.
SR
.
Xp_UndefFunc
,
base
.QName);
70
}
71
}
72
73
public
override
object
Evaluate
(
XPathNodeIterator
nodeIterator
)
74
{
75
if
(
xsltContext
==
null
)
76
{
77
throw
XPathException
.
Create
(
System
.
SR
.
Xp_NoContext
);
78
}
79
object
[]
array
=
new
object
[
_args
.
Count
];
80
for
(
int
i = 0; i <
_args
.
Count
; i++)
81
{
82
array
[i] =
_args
[i].Evaluate(
nodeIterator
);
83
if
(
array
[i]
is
XPathNodeIterator
)
84
{
85
array
[i] =
new
XPathSelectionIterator
(
nodeIterator
.Current,
_args
[i]);
86
}
87
}
88
try
89
{
90
return
ProcessResult
(
_function
.
Invoke
(
xsltContext
,
array
,
nodeIterator
.Current));
91
}
92
catch
(
Exception
innerException
)
93
{
94
throw
XPathException
.
Create
(
System
.
SR
.
Xp_FunctionFailed
,
base
.QName,
innerException
);
95
}
96
}
97
98
public
override
XPathNavigator
MatchNode
(
XPathNavigator
navigator
)
99
{
100
if
(
name
!=
"key"
&&
prefix
.Length != 0)
101
{
102
throw
XPathException
.
Create
(
System
.
SR
.
Xp_InvalidPattern
);
103
}
104
Evaluate
(
new
XPathSingletonIterator
(
navigator
,
moved
:
true
));
105
XPathNavigator
xPathNavigator
=
null
;
106
while
((
xPathNavigator
=
Advance
()) !=
null
)
107
{
108
if
(
xPathNavigator
.IsSamePosition(
navigator
))
109
{
110
return
xPathNavigator
;
111
}
112
}
113
return
xPathNavigator
;
114
}
115
116
public
override
XPathNodeIterator
Clone
()
117
{
118
return
new
FunctionQuery
(
this
);
119
}
120
}
MS.Internal.Xml.XPath.ExtensionQuery.name
string name
Definition
ExtensionQuery.cs:11
MS.Internal.Xml.XPath.ExtensionQuery.xsltContext
XsltContext xsltContext
Definition
ExtensionQuery.cs:13
MS.Internal.Xml.XPath.ExtensionQuery.ProcessResult
object ProcessResult(object value)
Definition
ExtensionQuery.cs:107
MS.Internal.Xml.XPath.ExtensionQuery.Advance
override XPathNavigator Advance()
Definition
ExtensionQuery.cs:94
MS.Internal.Xml.XPath.ExtensionQuery.prefix
string prefix
Definition
ExtensionQuery.cs:9
MS.Internal.Xml.XPath.ExtensionQuery
Definition
ExtensionQuery.cs:8
MS.Internal.Xml.XPath.FunctionQuery.FunctionQuery
FunctionQuery(string prefix, string name, List< Query > args)
Definition
FunctionQuery.cs:27
MS.Internal.Xml.XPath.FunctionQuery.Evaluate
override object Evaluate(XPathNodeIterator nodeIterator)
Definition
FunctionQuery.cs:73
MS.Internal.Xml.XPath.FunctionQuery.FunctionQuery
FunctionQuery(FunctionQuery other)
Definition
FunctionQuery.cs:33
MS.Internal.Xml.XPath.FunctionQuery._args
readonly IList< Query > _args
Definition
FunctionQuery.cs:10
MS.Internal.Xml.XPath.FunctionQuery.SetXsltContext
override void SetXsltContext(XsltContext context)
Definition
FunctionQuery.cs:46
MS.Internal.Xml.XPath.FunctionQuery.Clone
override XPathNodeIterator Clone()
Definition
FunctionQuery.cs:116
MS.Internal.Xml.XPath.FunctionQuery.StaticType
override XPathResultType StaticType
Definition
FunctionQuery.cs:15
MS.Internal.Xml.XPath.FunctionQuery.MatchNode
override XPathNavigator MatchNode(XPathNavigator navigator)
Definition
FunctionQuery.cs:98
MS.Internal.Xml.XPath.FunctionQuery._function
IXsltContextFunction _function
Definition
FunctionQuery.cs:12
MS.Internal.Xml.XPath.FunctionQuery
Definition
FunctionQuery.cs:9
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.XPathSelectionIterator
Definition
XPathSelectionIterator.cs:6
MS.Internal.Xml.XPath.XPathSingletonIterator
Definition
XPathSingletonIterator.cs:6
System.Collections.Generic.Dictionary.Count
int Count
Definition
Dictionary.cs:682
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Exception
Definition
Exception.cs:15
System.SR.Xp_FunctionFailed
static string Xp_FunctionFailed
Definition
SR.cs:1262
System.SR.Xp_NoContext
static string Xp_NoContext
Definition
SR.cs:1256
System.SR.Xp_InvalidPattern
static string Xp_InvalidPattern
Definition
SR.cs:1248
System.SR.Xp_UndefFunc
static string Xp_UndefFunc
Definition
SR.cs:1260
System.SR
Definition
SR.cs:7
System.Xml.XPath.XPathException.Create
static XPathException Create(string res)
Definition
XPathException.cs:77
System.Xml.XPath.XPathException
Definition
XPathException.cs:10
System.Xml.XPath.XPathNavigator
Definition
XPathNavigator.cs:15
System.Xml.XPath.XPathNodeIterator
Definition
XPathNodeIterator.cs:8
System.Xml.Xsl.XsltContext.ResolveFunction
IXsltContextFunction ResolveFunction(string prefix, string name, XPathResultType[] ArgTypes)
System.Xml.Xsl.XsltContext
Definition
XsltContext.cs:6
System.Xml.Xsl.IXsltContextFunction.ReturnType
XPathResultType ReturnType
Definition
IXsltContextFunction.cs:11
System.Xml.Xsl.IXsltContextFunction.Invoke
object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
System.Xml.Xsl.IXsltContextFunction
Definition
IXsltContextFunction.cs:6
MS.Internal.Xml.XPath
Definition
AbsoluteQuery.cs:3
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Xml.XPath.XPathResultType
XPathResultType
Definition
XPathResultType.cs:4
System.Xml.XPath
Definition
Extensions.cs:5
System.Xml.Xsl
Definition
BranchingContext.cs:1
System.ExceptionArgument.other
@ other
System.ExceptionArgument.array
@ array
System
Definition
BlockingCollection.cs:8
source
System.Private.Xml
MS.Internal.Xml.XPath
FunctionQuery.cs
Generated by
1.10.0