Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XName.cs
Go to the documentation of this file.
3
4namespace System.Xml.Linq;
5
6public sealed class XName : IEquatable<XName>, ISerializable
7{
8 private readonly XNamespace _ns;
9
10 private readonly string _localName;
11
12 private readonly int _hashCode;
13
14 public string LocalName => _localName;
15
17
19
20 internal XName(XNamespace ns, string localName)
21 {
22 _ns = ns;
24 _hashCode = ns.GetHashCode() ^ localName.GetHashCode();
25 }
26
27 public override string ToString()
28 {
29 if (_ns.NamespaceName.Length == 0)
30 {
31 return _localName;
32 }
33 return "{" + _ns.NamespaceName + "}" + _localName;
34 }
35
36 public static XName Get(string expandedName)
37 {
38 if (expandedName == null)
39 {
40 throw new ArgumentNullException("expandedName");
41 }
42 if (expandedName.Length == 0)
43 {
45 }
46 if (expandedName[0] == '{')
47 {
48 int num = expandedName.LastIndexOf('}');
49 if (num <= 1 || num == expandedName.Length - 1)
50 {
52 }
53 return XNamespace.Get(expandedName, 1, num - 1).GetName(expandedName, num + 1, expandedName.Length - num - 1);
54 }
55 return XNamespace.None.GetName(expandedName);
56 }
57
58 public static XName Get(string localName, string namespaceName)
59 {
60 return XNamespace.Get(namespaceName).GetName(localName);
61 }
62
63 [CLSCompliant(false)]
64 [return: NotNullIfNotNull("expandedName")]
65 public static implicit operator XName?(string? expandedName)
66 {
67 if (expandedName == null)
68 {
69 return null;
70 }
71 return Get(expandedName);
72 }
73
74 public override bool Equals([NotNullWhen(true)] object? obj)
75 {
76 return this == obj;
77 }
78
79 public override int GetHashCode()
80 {
81 return _hashCode;
82 }
83
84 public static bool operator ==(XName? left, XName? right)
85 {
86 return (object)left == right;
87 }
88
89 public static bool operator !=(XName? left, XName? right)
90 {
91 return (object)left != right;
92 }
93
95 {
96 return (object)this == other;
97 }
98
103}
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Argument_InvalidExpandedName
Definition SR.cs:22
Definition SR.cs:7
static bool operator==(XName? left, XName? right)
Definition XName.cs:84
override string ToString()
Definition XName.cs:27
static XName Get(string expandedName)
Definition XName.cs:36
readonly int _hashCode
Definition XName.cs:12
string NamespaceName
Definition XName.cs:18
XNamespace Namespace
Definition XName.cs:16
static bool operator!=(XName? left, XName? right)
Definition XName.cs:89
XName(XNamespace ns, string localName)
Definition XName.cs:20
readonly XNamespace _ns
Definition XName.cs:8
readonly string _localName
Definition XName.cs:10
static XName Get(string localName, string namespaceName)
Definition XName.cs:58
override bool Equals([NotNullWhen(true)] object? obj)
Definition XName.cs:74
override int GetHashCode()
Definition XName.cs:79
override int GetHashCode()
Definition XNamespace.cs:85
static XNamespace Get(string namespaceName)
Definition XNamespace.cs:51
static XNamespace None
Definition XNamespace.cs:24
static string VerifyNCName(string name)
bool Equals(T? other)
void GetObjectData(SerializationInfo info, StreamingContext context)