Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
QueryOutputWriterV1.cs
Go to the documentation of this file.
2
3namespace System.Xml;
4
5internal sealed class QueryOutputWriterV1 : XmlWriter
6{
7 private readonly XmlWriter _wrapped;
8
9 private bool _inCDataSection;
10
12
13 private readonly BitStack _bitsCData;
14
15 private readonly XmlQualifiedName _qnameCData;
16
17 private bool _outputDocType;
18
19 private bool _inAttr;
20
21 private readonly string _systemId;
22
23 private readonly string _publicId;
24
26
28 {
30 _systemId = settings.DocTypeSystem;
31 _publicId = settings.DocTypePublic;
32 if (settings.OutputMethod == XmlOutputMethod.Xml)
33 {
34 bool flag = false;
35 if (_systemId != null)
36 {
37 flag = true;
38 _outputDocType = true;
39 }
40 if (settings.Standalone == XmlStandalone.Yes)
41 {
42 flag = true;
43 }
44 if (flag)
45 {
46 if (settings.Standalone == XmlStandalone.Yes)
47 {
49 }
50 else
51 {
53 }
54 }
55 if (settings.CDataSectionElements == null || settings.CDataSectionElements.Count <= 0)
56 {
57 return;
58 }
59 _bitsCData = new BitStack();
63 {
65 }
66 _bitsCData.PushBit(bit: false);
67 }
68 else if (settings.OutputMethod == XmlOutputMethod.Html && (_systemId != null || _publicId != null))
69 {
70 _outputDocType = true;
71 }
72 }
73
74 public override void WriteStartDocument()
75 {
77 }
78
79 public override void WriteStartDocument(bool standalone)
80 {
82 }
83
84 public override void WriteEndDocument()
85 {
87 }
88
89 public override void WriteDocType(string name, string pubid, string sysid, string subset)
90 {
91 if (_publicId == null && _systemId == null)
92 {
94 }
95 }
96
97 public override void WriteStartElement(string prefix, string localName, string ns)
98 {
100 if (_outputDocType)
101 {
103 if (writeState == WriteState.Start || writeState == WriteState.Prolog)
104 {
105 _wrapped.WriteDocType(string.IsNullOrEmpty(prefix) ? localName : (prefix + ":" + localName), _publicId, _systemId, null);
106 }
107 _outputDocType = false;
108 }
109 _wrapped.WriteStartElement(prefix, localName, ns);
110 if (_lookupCDataElems != null)
111 {
112 _qnameCData.Init(localName, ns);
114 }
115 }
116
117 public override void WriteEndElement()
118 {
121 if (_lookupCDataElems != null)
122 {
124 }
125 }
126
127 public override void WriteFullEndElement()
128 {
131 if (_lookupCDataElems != null)
132 {
134 }
135 }
136
137 public override void WriteStartAttribute(string prefix, string localName, string ns)
138 {
139 _inAttr = true;
140 _wrapped.WriteStartAttribute(prefix, localName, ns);
141 }
142
143 public override void WriteEndAttribute()
144 {
145 _inAttr = false;
147 }
148
149 public override void WriteCData(string text)
150 {
152 }
153
154 public override void WriteComment(string text)
155 {
158 }
159
160 public override void WriteProcessingInstruction(string name, string text)
161 {
164 }
165
166 public override void WriteWhitespace(string ws)
167 {
169 {
171 }
172 else
173 {
175 }
176 }
177
178 public override void WriteString(string text)
179 {
181 {
183 }
184 else
185 {
187 }
188 }
189
190 public override void WriteChars(char[] buffer, int index, int count)
191 {
193 {
194 _wrapped.WriteCData(new string(buffer, index, count));
195 }
196 else
197 {
199 }
200 }
201
202 public override void WriteBase64(byte[] buffer, int index, int count)
203 {
204 if (!_inAttr && !_inCDataSection)
205 {
207 }
209 }
210
211 public override void WriteEntityRef(string name)
212 {
215 }
216
217 public override void WriteCharEntity(char ch)
218 {
221 }
222
228
229 public override void WriteRaw(char[] buffer, int index, int count)
230 {
232 {
233 _wrapped.WriteCData(new string(buffer, index, count));
234 }
235 else
236 {
238 }
239 }
240
241 public override void WriteRaw(string data)
242 {
244 {
245 _wrapped.WriteCData(data);
246 }
247 else
248 {
249 _wrapped.WriteRaw(data);
250 }
251 }
252
253 public override void Close()
254 {
255 _wrapped.Close();
256 }
257
258 public override void Flush()
259 {
260 _wrapped.Flush();
261 }
262
263 public override string LookupPrefix(string ns)
264 {
265 return _wrapped.LookupPrefix(ns);
266 }
267
268 private bool StartCDataSection()
269 {
270 if (_lookupCDataElems != null && _bitsCData.PeekBit())
271 {
272 _inCDataSection = true;
273 return true;
274 }
275 return false;
276 }
277
278 private void EndCDataSection()
279 {
280 _inCDataSection = false;
281 }
282}
void PushBit(bool bit)
Definition BitStack.cs:16
override void WriteStartAttribute(string prefix, string localName, string ns)
override void WriteString(string text)
override void WriteDocType(string name, string pubid, string sysid, string subset)
override void WriteStartElement(string prefix, string localName, string ns)
override void WriteChars(char[] buffer, int index, int count)
override void WriteProcessingInstruction(string name, string text)
QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
readonly Dictionary< XmlQualifiedName, XmlQualifiedName > _lookupCDataElems
override void WriteRaw(string data)
override void WriteSurrogateCharEntity(char lowChar, char highChar)
override void WriteRaw(char[] buffer, int index, int count)
override void WriteStartDocument(bool standalone)
override string LookupPrefix(string ns)
override void WriteCData(string text)
override void WriteBase64(byte[] buffer, int index, int count)
override void WriteCharEntity(char ch)
override void WriteWhitespace(string ws)
override void WriteComment(string text)
readonly XmlQualifiedName _qnameCData
override void WriteEntityRef(string name)
void Init(string name, string ns)
List< XmlQualifiedName > CDataSectionElements
void WriteCData(string? text)
void WriteComment(string? text)
void WriteProcessingInstruction(string name, string? text)
virtual void Close()
Definition XmlWriter.cs:110
void WriteSurrogateCharEntity(char lowChar, char highChar)
void WriteEntityRef(string name)
void WriteString(string? text)
string? LookupPrefix(string ns)
void WriteChars(char[] buffer, int index, int count)
void WriteBase64(byte[] buffer, int index, int count)
void WriteCharEntity(char ch)
void WriteRaw(char[] buffer, int index, int count)
WriteState WriteState
Definition XmlWriter.cs:16
void WriteStartAttribute(string localName, string? ns)
Definition XmlWriter.cs:67
void WriteWhitespace(string? ws)
void WriteDocType(string name, string? pubid, string? sysid, string? subset)
void WriteStartElement(string localName, string? ns)
Definition XmlWriter.cs:30