Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlDeclaration.cs
Go to the documentation of this file.
2using System.Text;
3
4namespace System.Xml;
5
7{
8 private string _version;
9
10 private string _encoding;
11
12 private string _standalone;
13
14 public string Version
15 {
16 get
17 {
18 return _version;
19 }
20 [MemberNotNull("_version")]
21 internal set
22 {
24 }
25 }
26
27 public string Encoding
28 {
29 get
30 {
31 return _encoding;
32 }
33 [MemberNotNull("_encoding")]
35 set
36 {
37 _encoding = ((value == null) ? string.Empty : value);
38 }
39 }
40
41 public string Standalone
42 {
43 get
44 {
45 return _standalone;
46 }
47 [MemberNotNull("_standalone")]
49 set
50 {
51 if (value == null)
52 {
53 _standalone = string.Empty;
54 return;
55 }
56 if (value.Length == 0 || value == "yes" || value == "no")
57 {
59 return;
60 }
62 }
63 }
64
65 public override string? Value
66 {
67 get
68 {
69 return InnerText;
70 }
71 set
72 {
74 }
75 }
76
77 public override string InnerText
78 {
79 get
80 {
82 stringBuilder.Append("version=\"");
83 stringBuilder.Append(Version);
84 stringBuilder.Append('"');
85 if (Encoding.Length > 0)
86 {
87 stringBuilder.Append(" encoding=\"");
88 stringBuilder.Append(Encoding);
89 stringBuilder.Append('"');
90 }
91 if (Standalone.Length > 0)
92 {
93 stringBuilder.Append(" standalone=\"");
95 stringBuilder.Append('"');
96 }
98 }
99 set
100 {
101 string version = null;
102 string encoding = null;
103 string standalone = null;
104 string encoding2 = Encoding;
105 string standalone2 = Standalone;
106 string version2 = Version;
108 try
109 {
110 if (version != null && !IsValidXmlVersion(version))
111 {
113 }
114 Version = version;
115 if (encoding != null)
116 {
117 Encoding = encoding;
118 }
119 if (standalone != null)
120 {
122 }
123 }
124 catch
125 {
129 throw;
130 }
131 }
132 }
133
134 public override string Name => "xml";
135
136 public override string LocalName => Name;
137
138 public override XmlNodeType NodeType => XmlNodeType.XmlDeclaration;
139
140 protected internal XmlDeclaration(string version, string? encoding, string? standalone, XmlDocument doc)
141 : base(doc)
142 {
143 if (!IsValidXmlVersion(version))
144 {
146 }
147 if (standalone != null && standalone.Length > 0 && standalone != "yes" && standalone != "no")
148 {
150 }
151 Encoding = encoding;
153 Version = version;
154 }
155
156 public override XmlNode CloneNode(bool deep)
157 {
159 }
160
161 public override void WriteTo(XmlWriter w)
162 {
163 w.WriteProcessingInstruction(Name, InnerText);
164 }
165
166 public override void WriteContentTo(XmlWriter w)
167 {
168 }
169
170 private bool IsValidXmlVersion(string ver)
171 {
172 if (ver.Length >= 3 && ver[0] == '1' && ver[1] == '.')
173 {
174 return XmlCharType.IsOnlyDigits(ver, 2, ver.Length - 2);
175 }
176 return false;
177 }
178}
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Xdom_Version
Definition SR.cs:1288
static string Xdom_standalone
Definition SR.cs:1290
Definition SR.cs:7
static string GetStringAndRelease(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)
static bool IsOnlyDigits(string str, int startPos, int len)
override XmlNode CloneNode(bool deep)
XmlDeclaration(string version, string? encoding, string? standalone, XmlDocument doc)
bool IsValidXmlVersion(string ver)
override void WriteContentTo(XmlWriter w)
override XmlNodeType NodeType
override void WriteTo(XmlWriter w)
virtual XmlDeclaration CreateXmlDeclaration(string version, string? encoding, string? standalone)
static void ParseXmlDeclarationValue(string strValue, out string version, out string encoding, out string standalone)
Definition XmlLoader.cs:813
virtual ? XmlDocument OwnerDocument
Definition XmlNode.cs:109