Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Write() [2/2]

void System.Xml.XmlTextEncoder.Write ( string text)
inlinepackage

Definition at line 210 of file XmlTextEncoder.cs.

211 {
212 if (text == null)
213 {
214 return;
215 }
216 if (_cacheAttrValue)
217 {
219 }
220 int length = text.Length;
221 int i = 0;
222 int num = 0;
223 char c = '\0';
224 while (true)
225 {
226 if (i < length && XmlCharType.IsAttributeValueChar(c = text[i]))
227 {
228 i++;
229 continue;
230 }
231 if (i == length)
232 {
234 return;
235 }
236 if (_inAttribute)
237 {
238 if (c != '\t')
239 {
240 break;
241 }
242 i++;
243 }
244 else
245 {
246 if (c != '\t' && c != '\n' && c != '\r' && c != '"' && c != '\'')
247 {
248 break;
249 }
250 i++;
251 }
252 }
253 char[] helperBuffer = new char[256];
254 while (true)
255 {
256 if (num < i)
257 {
258 WriteStringFragment(text, num, i - num, helperBuffer);
259 }
260 if (i == length)
261 {
262 break;
263 }
264 switch (c)
265 {
266 case '\t':
268 break;
269 case '\n':
270 case '\r':
271 if (_inAttribute)
272 {
274 }
275 else
276 {
278 }
279 break;
280 case '<':
281 WriteEntityRefImpl("lt");
282 break;
283 case '>':
284 WriteEntityRefImpl("gt");
285 break;
286 case '&':
287 WriteEntityRefImpl("amp");
288 break;
289 case '\'':
290 if (_inAttribute && _quoteChar == c)
291 {
292 WriteEntityRefImpl("apos");
293 }
294 else
295 {
296 _textWriter.Write('\'');
297 }
298 break;
299 case '"':
300 if (_inAttribute && _quoteChar == c)
301 {
302 WriteEntityRefImpl("quot");
303 }
304 else
305 {
306 _textWriter.Write('"');
307 }
308 break;
309 default:
310 if (XmlCharType.IsHighSurrogate(c))
311 {
312 if (i + 1 >= length)
313 {
314 throw XmlConvert.CreateInvalidSurrogatePairException(text[i], c);
315 }
316 WriteSurrogateChar(text[++i], c);
317 }
318 else
319 {
320 if (XmlCharType.IsLowSurrogate(c))
321 {
322 throw XmlConvert.CreateInvalidHighSurrogateCharException(c);
323 }
325 }
326 break;
327 }
328 i++;
329 num = i;
330 for (; i < length; i++)
331 {
332 if (!XmlCharType.IsAttributeValueChar(c = text[i]))
333 {
334 break;
335 }
336 }
337 }
338 }
virtual void Write(char value)
StringBuilder Append(char value, int repeatCount)
void WriteEntityRefImpl(string name)
void WriteSurrogateChar(char lowChar, char highChar)
void WriteCharEntityImpl(char ch)
void WriteStringFragment(string str, int offset, int count, char[] helperBuffer)
readonly TextWriter _textWriter

References System.Xml.XmlTextEncoder._attrValue, System.Xml.XmlTextEncoder._cacheAttrValue, System.Xml.XmlTextEncoder._inAttribute, System.Xml.XmlTextEncoder._quoteChar, System.Xml.XmlTextEncoder._textWriter, System.Text.StringBuilder.Append(), System.Xml.XmlConvert.CreateInvalidHighSurrogateCharException(), System.Xml.XmlConvert.CreateInvalidSurrogatePairException(), System.Xml.Dictionary, System.Xml.XmlCharType.IsAttributeValueChar(), System.Xml.XmlCharType.IsHighSurrogate(), System.Xml.XmlCharType.IsLowSurrogate(), System.length, System.Text.StringBuilder.Length, System.text, System.IO.TextWriter.Write(), System.Xml.XmlTextEncoder.WriteCharEntityImpl(), System.Xml.XmlTextEncoder.WriteEntityRefImpl(), System.Xml.XmlTextEncoder.WriteStringFragment(), and System.Xml.XmlTextEncoder.WriteSurrogateChar().