Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlQualifiedName.cs
Go to the documentation of this file.
2
3namespace System.Xml;
4
5public class XmlQualifiedName
6{
7 private string _name;
8
9 private string _ns;
10
11 private int _hash;
12
13 public static readonly XmlQualifiedName Empty = new XmlQualifiedName(string.Empty);
14
15 public string Namespace => _ns;
16
17 public string Name => _name;
18
19 public bool IsEmpty
20 {
21 get
22 {
23 if (Name.Length == 0)
24 {
25 return Namespace.Length == 0;
26 }
27 return false;
28 }
29 }
30
33 {
34 }
35
36 public XmlQualifiedName(string? name)
37 : this(name, string.Empty)
38 {
39 }
40
41 public XmlQualifiedName(string? name, string? ns)
42 {
43 _ns = ns ?? string.Empty;
44 _name = name ?? string.Empty;
45 }
46
47 public override int GetHashCode()
48 {
49 if (_hash == 0)
50 {
51 _hash = Name.GetHashCode();
52 }
53 return _hash;
54 }
55
56 public override string ToString()
57 {
58 if (Namespace.Length != 0)
59 {
60 return Namespace + ":" + Name;
61 }
62 return Name;
63 }
64
65 public override bool Equals([NotNullWhen(true)] object? other)
66 {
67 if (this == other)
68 {
69 return true;
70 }
72 if (xmlQualifiedName != null)
73 {
74 if (Name == xmlQualifiedName.Name)
75 {
76 return Namespace == xmlQualifiedName.Namespace;
77 }
78 return false;
79 }
80 return false;
81 }
82
84 {
85 if ((object)a == b)
86 {
87 return true;
88 }
89 if ((object)a == null || (object)b == null)
90 {
91 return false;
92 }
93 if (a.Name == b.Name)
94 {
95 return a.Namespace == b.Namespace;
96 }
97 return false;
98 }
99
101 {
102 return !(a == b);
103 }
104
105 public static string ToString(string name, string ns)
106 {
107 if (ns != null && ns.Length != 0)
108 {
109 return ns + ":" + name;
110 }
111 return name;
112 }
113
114 internal void Init(string name, string ns)
115 {
116 _name = name ?? string.Empty;
117 _ns = ns ?? string.Empty;
118 _hash = 0;
119 }
120
121 internal void SetNamespace(string ns)
122 {
123 _ns = ns ?? string.Empty;
124 }
125
126 internal void Verify()
127 {
129 if (_ns.Length != 0)
130 {
132 }
133 }
134
136 {
137 _name = nameTable.Add(_name);
138 _ns = nameTable.Add(_ns);
139 }
140
142 {
144 string text = nsmgr.LookupNamespace(prefix);
145 if (text == null)
146 {
147 if (prefix.Length != 0)
148 {
150 }
151 text = string.Empty;
152 }
153 return new XmlQualifiedName(localName, text);
154 }
155
157 {
158 return (XmlQualifiedName)MemberwiseClone();
159 }
160}
static string Xml_UnknownNs
Definition SR.cs:72
Definition SR.cs:7
static int ParseQNameThrow(string s)
static string VerifyNCName(string name)
static Uri ToUri(string s)
void Atomize(XmlNameTable nameTable)
static string ToString(string name, string ns)
static XmlQualifiedName Parse(string s, IXmlNamespaceResolver nsmgr, out string prefix)
override bool Equals([NotNullWhen(true)] object? other)
XmlQualifiedName(string? name, string? ns)
static bool operator!=(XmlQualifiedName? a, XmlQualifiedName? b)
static bool operator==(XmlQualifiedName? a, XmlQualifiedName? b)
void Init(string name, string ns)