Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XPathEvaluator.cs
Go to the documentation of this file.
1
using
System.Collections.Generic
;
2
using
System.Runtime.InteropServices
;
3
using
System.Xml.Linq
;
4
5
namespace
System.Xml.XPath
;
6
7
[
StructLayout
(
LayoutKind
.Sequential, Size = 1)]
8
internal
readonly
struct
XPathEvaluator
9
{
10
public
object
Evaluate<T>
(
XNode
node
,
string
expression
,
IXmlNamespaceResolver
resolver
)
where
T
:
class
11
{
12
XPathNavigator
xPathNavigator
=
node
.CreateNavigator();
13
object
obj
=
xPathNavigator
.Evaluate(
expression
,
resolver
);
14
if
(
obj
is
XPathNodeIterator
result)
15
{
16
return
EvaluateIterator<T>
(result);
17
}
18
if
(!(
obj
is
T))
19
{
20
throw
new
InvalidOperationException
(
System
.
SR
.
Format
(
System
.
SR
.
InvalidOperation_UnexpectedEvaluation
,
obj
.GetType()));
21
}
22
return
(T)
obj
;
23
}
24
25
private
IEnumerable<T>
EvaluateIterator<T>
(
XPathNodeIterator
result)
26
{
27
foreach
(
XPathNavigator
item
in
result)
28
{
29
object
r
=
item
.UnderlyingObject;
30
if
(!(
r
is
T))
31
{
32
throw
new
InvalidOperationException
(
System
.
SR
.
Format
(
System
.
SR
.
InvalidOperation_UnexpectedEvaluation
,
r
.GetType()));
33
}
34
yield
return
(T)
r
;
35
XText
t =
r
as
XText
;
36
if
(t ==
null
|| t.GetParent() ==
null
)
37
{
38
continue
;
39
}
40
do
41
{
42
t =
t.NextNode
as
XText
;
43
if
(t ==
null
)
44
{
45
break
;
46
}
47
yield
return
(T)(object)t;
48
}
49
while
(t != t.GetParent().LastNode);
50
}
51
}
52
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.SR.InvalidOperation_UnexpectedEvaluation
static string InvalidOperation_UnexpectedEvaluation
Definition
SR.cs:72
System.SR.Format
static string Format(string resourceFormat, object p1)
Definition
SR.cs:118
System.SR
Definition
SR.cs:7
System.Xml.Linq.XNode
Definition
XNode.cs:11
System.Xml.Linq.XText
Definition
XText.cs:8
System.Xml.XPath.XPathNavigator
Definition
XPathNavigator.cs:15
System.Xml.XPath.XPathNodeIterator
Definition
XPathNodeIterator.cs:8
System.Xml.IXmlNamespaceResolver
Definition
IXmlNamespaceResolver.cs:6
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Runtime.InteropServices.LayoutKind
LayoutKind
Definition
LayoutKind.cs:4
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.Xml.Linq
Definition
BaseUriAnnotation.cs:1
System.Xml.XPath
Definition
Extensions.cs:5
System.Xml.PrefixHandleType.T
@ T
System.Xml.ValueHandleType.Dictionary
@ Dictionary
System.ExceptionArgument.item
@ item
System.ExceptionArgument.obj
@ obj
System
Definition
BlockingCollection.cs:8
System.Xml.XPath.XPathEvaluator.EvaluateIterator< T >
IEnumerable< T > EvaluateIterator< T >(XPathNodeIterator result)
Definition
XPathEvaluator.cs:25
System.Xml.XPath.XPathEvaluator.Evaluate< T >
object Evaluate< T >(XNode node, string expression, IXmlNamespaceResolver resolver)
Definition
XPathEvaluator.cs:10
System.Xml.XPath.XPathEvaluator
Definition
XPathEvaluator.cs:9
source
System.Private.Xml.Linq
System.Xml.XPath
XPathEvaluator.cs
Generated by
1.10.0