Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Extensions.cs
Go to the documentation of this file.
2using System.Linq;
4
6
7public static class Extensions
8{
10 {
11 return node.CreateNavigator(null);
12 }
13
15 {
16 if (node == null)
17 {
18 throw new ArgumentNullException("node");
19 }
21 {
23 }
24 if (node is XText xText)
25 {
26 if (xText.GetParent() is XDocument)
27 {
29 }
31 }
32 return new XNodeNavigator(node, nameTable);
33 }
34
35 public static object XPathEvaluate(this XNode node, string expression)
36 {
37 return node.XPathEvaluate(expression, null);
38 }
39
40 public static object XPathEvaluate(this XNode node, string expression, IXmlNamespaceResolver? resolver)
41 {
42 if (node == null)
43 {
44 throw new ArgumentNullException("node");
45 }
46 return default(XPathEvaluator).Evaluate<object>(node, expression, resolver);
47 }
48
49 public static XElement? XPathSelectElement(this XNode node, string expression)
50 {
51 return node.XPathSelectElement(expression, null);
52 }
53
55 {
56 return node.XPathSelectElements(expression, resolver).FirstOrDefault();
57 }
58
60 {
61 return node.XPathSelectElements(expression, null);
62 }
63
65 {
66 if (node == null)
67 {
68 throw new ArgumentNullException("node");
69 }
71 }
72
73 private static XText CalibrateText(XText n)
74 {
75 XContainer parent = n.GetParent();
76 if (parent == null)
77 {
78 return n;
79 }
80 foreach (XNode item in parent.Nodes())
81 {
82 if (item is XText result && item == n)
83 {
84 return result;
85 }
86 }
87 return null;
88 }
89}
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Argument_CreateNavigator
Definition SR.cs:68
Definition SR.cs:7
static object XPathEvaluate(this XNode node, string expression, IXmlNamespaceResolver? resolver)
Definition Extensions.cs:40
static XText CalibrateText(XText n)
Definition Extensions.cs:73
static ? XElement XPathSelectElement(this XNode node, string expression)
Definition Extensions.cs:49
static IEnumerable< XElement > XPathSelectElements(this XNode node, string expression, IXmlNamespaceResolver? resolver)
Definition Extensions.cs:64
static ? XElement XPathSelectElement(this XNode node, string expression, IXmlNamespaceResolver? resolver)
Definition Extensions.cs:54
static IEnumerable< XElement > XPathSelectElements(this XNode node, string expression)
Definition Extensions.cs:59
static XPathNavigator CreateNavigator(this XNode node)
Definition Extensions.cs:9
static object XPathEvaluate(this XNode node, string expression)
Definition Extensions.cs:35
static XPathNavigator CreateNavigator(this XNode node, XmlNameTable? nameTable)
Definition Extensions.cs:14