Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlUtf8RawTextWriter.cs
Go to the documentation of this file.
2using System.IO;
4using System.Text;
6
7namespace System.Xml;
8
10{
11 private readonly bool _useAsync;
12
13 protected byte[] _bufBytes;
14
15 protected Stream _stream;
16
18
19 protected int _bufPos = 1;
20
21 protected int _textPos = 1;
22
23 protected int _contentPos;
24
25 protected int _cdataPos;
26
27 protected int _attrEndPos;
28
29 protected int _bufLen = 6144;
30
31 protected bool _writeToNull;
32
33 protected bool _hadDoubleBracket;
34
35 protected bool _inAttributeValue;
36
38
39 protected bool _closeOutput;
40
41 protected bool _omitXmlDeclaration;
42
43 protected string _newLineChars;
44
45 protected bool _checkCharacters;
46
48
50
51 protected bool _autoXmlDeclaration;
52
53 protected bool _mergeCDataSections;
54
74
75 internal override bool SupportsNamespaceDeclarationInChunks => true;
76
93
95 : this(settings)
96 {
98 _encoding = settings.Encoding;
99 if (settings.Async)
100 {
101 _bufLen = 65536;
102 }
103 _bufBytes = new byte[_bufLen + 32];
104 if (!stream.CanSeek || stream.Position == 0L)
105 {
107 if (preamble.Length != 0)
108 {
109 preamble.CopyTo(new Span<byte>(_bufBytes).Slice(1));
110 _bufPos += preamble.Length;
111 _textPos += preamble.Length;
112 }
113 }
114 if (settings.AutoXmlDeclaration)
115 {
117 _autoXmlDeclaration = true;
118 }
119 }
120
122 {
124 {
125 RawText("<?xml version=\"");
126 RawText("1.0");
127 if (_encoding != null)
128 {
129 RawText("\" encoding=\"");
131 }
132 if (standalone != 0)
133 {
134 RawText("\" standalone=\"");
135 RawText((standalone == XmlStandalone.Yes) ? "yes" : "no");
136 }
137 RawText("\"?>");
138 }
139 }
140
141 internal override void WriteXmlDeclaration(string xmldecl)
142 {
144 {
146 }
147 }
148
149 public override void WriteDocType(string name, string pubid, string sysid, string subset)
150 {
151 RawText("<!DOCTYPE ");
152 RawText(name);
153 if (pubid != null)
154 {
155 RawText(" PUBLIC \"");
156 RawText(pubid);
157 RawText("\" \"");
158 if (sysid != null)
159 {
160 RawText(sysid);
161 }
162 _bufBytes[_bufPos++] = 34;
163 }
164 else if (sysid != null)
165 {
166 RawText(" SYSTEM \"");
167 RawText(sysid);
168 _bufBytes[_bufPos++] = 34;
169 }
170 else
171 {
172 _bufBytes[_bufPos++] = 32;
173 }
174 if (subset != null)
175 {
176 _bufBytes[_bufPos++] = 91;
178 _bufBytes[_bufPos++] = 93;
179 }
180 _bufBytes[_bufPos++] = 62;
181 }
182
183 public override void WriteStartElement(string prefix, string localName, string ns)
184 {
185 _bufBytes[_bufPos++] = 60;
186 if (prefix != null && prefix.Length != 0)
187 {
189 _bufBytes[_bufPos++] = 58;
190 }
191 RawText(localName);
193 }
194
195 internal override void StartElementContent()
196 {
197 _bufBytes[_bufPos++] = 62;
199 }
200
201 internal override void WriteEndElement(string prefix, string localName, string ns)
202 {
203 if (_contentPos != _bufPos)
204 {
205 _bufBytes[_bufPos++] = 60;
206 _bufBytes[_bufPos++] = 47;
207 if (prefix != null && prefix.Length != 0)
208 {
210 _bufBytes[_bufPos++] = 58;
211 }
212 RawText(localName);
213 _bufBytes[_bufPos++] = 62;
214 }
215 else
216 {
217 _bufPos--;
218 _bufBytes[_bufPos++] = 32;
219 _bufBytes[_bufPos++] = 47;
220 _bufBytes[_bufPos++] = 62;
221 }
222 }
223
224 internal override void WriteFullEndElement(string prefix, string localName, string ns)
225 {
226 _bufBytes[_bufPos++] = 60;
227 _bufBytes[_bufPos++] = 47;
228 if (prefix != null && prefix.Length != 0)
229 {
231 _bufBytes[_bufPos++] = 58;
232 }
233 RawText(localName);
234 _bufBytes[_bufPos++] = 62;
235 }
236
237 public override void WriteStartAttribute(string prefix, string localName, string ns)
238 {
239 if (_attrEndPos == _bufPos)
240 {
241 _bufBytes[_bufPos++] = 32;
242 }
243 if (prefix != null && prefix.Length > 0)
244 {
246 _bufBytes[_bufPos++] = 58;
247 }
248 RawText(localName);
249 _bufBytes[_bufPos++] = 61;
250 _bufBytes[_bufPos++] = 34;
251 _inAttributeValue = true;
252 }
253
254 public override void WriteEndAttribute()
255 {
256 _bufBytes[_bufPos++] = 34;
257 _inAttributeValue = false;
259 }
260
267
268 internal override void WriteStartNamespaceDeclaration(string prefix)
269 {
270 if (prefix.Length == 0)
271 {
272 RawText(" xmlns=\"");
273 }
274 else
275 {
276 RawText(" xmlns:");
278 _bufBytes[_bufPos++] = 61;
279 _bufBytes[_bufPos++] = 34;
280 }
281 _inAttributeValue = true;
282 }
283
284 internal override void WriteEndNamespaceDeclaration()
285 {
286 _inAttributeValue = false;
287 _bufBytes[_bufPos++] = 34;
289 }
290
291 public override void WriteCData(string text)
292 {
294 {
295 _bufPos -= 3;
296 }
297 else
298 {
299 _bufBytes[_bufPos++] = 60;
300 _bufBytes[_bufPos++] = 33;
301 _bufBytes[_bufPos++] = 91;
302 _bufBytes[_bufPos++] = 67;
303 _bufBytes[_bufPos++] = 68;
304 _bufBytes[_bufPos++] = 65;
305 _bufBytes[_bufPos++] = 84;
306 _bufBytes[_bufPos++] = 65;
307 _bufBytes[_bufPos++] = 91;
308 }
310 _bufBytes[_bufPos++] = 93;
311 _bufBytes[_bufPos++] = 93;
312 _bufBytes[_bufPos++] = 62;
315 }
316
317 public override void WriteComment(string text)
318 {
319 _bufBytes[_bufPos++] = 60;
320 _bufBytes[_bufPos++] = 33;
321 _bufBytes[_bufPos++] = 45;
322 _bufBytes[_bufPos++] = 45;
324 _bufBytes[_bufPos++] = 45;
325 _bufBytes[_bufPos++] = 45;
326 _bufBytes[_bufPos++] = 62;
327 }
328
329 public override void WriteProcessingInstruction(string name, string text)
330 {
331 _bufBytes[_bufPos++] = 60;
332 _bufBytes[_bufPos++] = 63;
333 RawText(name);
334 if (text.Length > 0)
335 {
336 _bufBytes[_bufPos++] = 32;
338 }
339 _bufBytes[_bufPos++] = 63;
340 _bufBytes[_bufPos++] = 62;
341 }
342
343 public override void WriteEntityRef(string name)
344 {
345 _bufBytes[_bufPos++] = 38;
346 RawText(name);
347 _bufBytes[_bufPos++] = 59;
348 if (_bufPos > _bufLen)
349 {
350 FlushBuffer();
351 }
353 }
354
355 public override void WriteCharEntity(char ch)
356 {
357 int num = ch;
358 string s = num.ToString("X", NumberFormatInfo.InvariantInfo);
360 {
362 }
363 _bufBytes[_bufPos++] = 38;
364 _bufBytes[_bufPos++] = 35;
365 _bufBytes[_bufPos++] = 120;
366 RawText(s);
367 _bufBytes[_bufPos++] = 59;
368 if (_bufPos > _bufLen)
369 {
370 FlushBuffer();
371 }
373 }
374
375 public unsafe override void WriteWhitespace(string ws)
376 {
377 fixed (char* ptr = ws)
378 {
379 char* pSrcEnd = ptr + ws.Length;
381 {
383 }
384 else
385 {
387 }
388 }
389 }
390
391 public unsafe override void WriteString(string text)
392 {
393 fixed (char* ptr = text)
394 {
395 char* pSrcEnd = ptr + text.Length;
397 {
399 }
400 else
401 {
403 }
404 }
405 }
406
407 public override void WriteSurrogateCharEntity(char lowChar, char highChar)
408 {
410 _bufBytes[_bufPos++] = 38;
411 _bufBytes[_bufPos++] = 35;
412 _bufBytes[_bufPos++] = 120;
413 RawText(num.ToString("X", NumberFormatInfo.InvariantInfo));
414 _bufBytes[_bufPos++] = 59;
416 }
417
418 public unsafe override void WriteChars(char[] buffer, int index, int count)
419 {
420 fixed (char* ptr = &buffer[index])
421 {
423 {
425 }
426 else
427 {
429 }
430 }
431 }
432
433 public unsafe override void WriteRaw(char[] buffer, int index, int count)
434 {
435 fixed (char* ptr = &buffer[index])
436 {
438 }
440 }
441
442 public unsafe override void WriteRaw(string data)
443 {
444 fixed (char* ptr = data)
445 {
446 WriteRawWithCharChecking(ptr, ptr + data.Length);
447 }
449 }
450
451 public override void Close()
452 {
453 try
454 {
455 FlushBuffer();
456 FlushEncoder();
457 }
458 finally
459 {
460 _writeToNull = true;
461 if (_stream != null)
462 {
463 try
464 {
465 _stream.Flush();
466 }
467 finally
468 {
469 try
470 {
471 if (_closeOutput)
472 {
474 }
475 }
476 finally
477 {
478 _stream = null;
479 }
480 }
481 }
482 }
483 }
484
485 public override void Flush()
486 {
487 FlushBuffer();
488 FlushEncoder();
489 if (_stream != null)
490 {
491 _stream.Flush();
492 }
493 }
494
495 protected virtual void FlushBuffer()
496 {
497 try
498 {
499 if (!_writeToNull && _bufPos - 1 > 0)
500 {
502 }
503 }
504 catch
505 {
506 _writeToNull = true;
507 throw;
508 }
509 finally
510 {
511 _bufBytes[0] = _bufBytes[_bufPos - 1];
513 {
515 _bufBytes[2] = _bufBytes[_bufPos + 1];
516 _bufBytes[3] = _bufBytes[_bufPos + 2];
517 }
518 _textPos = ((_textPos == _bufPos) ? 1 : 0);
519 _attrEndPos = ((_attrEndPos == _bufPos) ? 1 : 0);
520 _contentPos = 0;
521 _cdataPos = 0;
522 _bufPos = 1;
523 }
524 }
525
526 private void FlushEncoder()
527 {
528 }
529
530 protected unsafe void WriteAttributeTextBlock(char* pSrc, char* pSrcEnd)
531 {
532 fixed (byte* ptr = _bufBytes)
533 {
534 byte* ptr2 = ptr + _bufPos;
535 int num = 0;
536 while (true)
537 {
538 byte* ptr3 = ptr2 + (pSrcEnd - pSrc);
539 if (ptr3 > ptr + _bufLen)
540 {
541 ptr3 = ptr + _bufLen;
542 }
543 while (ptr2 < ptr3 && XmlCharType.IsAttributeValueChar((char)(num = *pSrc)) && num <= 127)
544 {
545 *ptr2 = (byte)num;
546 ptr2++;
547 pSrc++;
548 }
549 if (pSrc >= pSrcEnd)
550 {
551 break;
552 }
553 if (ptr2 >= ptr3)
554 {
555 _bufPos = (int)(ptr2 - ptr);
556 FlushBuffer();
557 ptr2 = ptr + 1;
558 continue;
559 }
560 switch (num)
561 {
562 case 38:
564 break;
565 case 60:
566 ptr2 = LtEntity(ptr2);
567 break;
568 case 62:
569 ptr2 = GtEntity(ptr2);
570 break;
571 case 34:
573 break;
574 case 39:
575 *ptr2 = (byte)num;
576 ptr2++;
577 break;
578 case 9:
580 {
581 *ptr2 = (byte)num;
582 ptr2++;
583 }
584 else
585 {
587 }
588 break;
589 case 13:
591 {
592 *ptr2 = (byte)num;
593 ptr2++;
594 }
595 else
596 {
598 }
599 break;
600 case 10:
602 {
603 *ptr2 = (byte)num;
604 ptr2++;
605 }
606 else
607 {
609 }
610 break;
611 default:
612 if (XmlCharType.IsSurrogate(num))
613 {
615 pSrc += 2;
616 }
617 else if (num <= 127 || num >= 65534)
618 {
619 ptr2 = InvalidXmlChar(num, ptr2, entitize: true);
620 pSrc++;
621 }
622 else
623 {
625 pSrc++;
626 }
627 continue;
628 }
629 pSrc++;
630 }
631 _bufPos = (int)(ptr2 - ptr);
632 }
633 }
634
635 protected unsafe void WriteElementTextBlock(char* pSrc, char* pSrcEnd)
636 {
637 fixed (byte* ptr = _bufBytes)
638 {
639 byte* ptr2 = ptr + _bufPos;
640 int num = 0;
641 while (true)
642 {
643 byte* ptr3 = ptr2 + (pSrcEnd - pSrc);
644 if (ptr3 > ptr + _bufLen)
645 {
646 ptr3 = ptr + _bufLen;
647 }
648 while (ptr2 < ptr3 && XmlCharType.IsAttributeValueChar((char)(num = *pSrc)) && num <= 127)
649 {
650 *ptr2 = (byte)num;
651 ptr2++;
652 pSrc++;
653 }
654 if (pSrc >= pSrcEnd)
655 {
656 break;
657 }
658 if (ptr2 >= ptr3)
659 {
660 _bufPos = (int)(ptr2 - ptr);
661 FlushBuffer();
662 ptr2 = ptr + 1;
663 continue;
664 }
665 switch (num)
666 {
667 case 38:
669 break;
670 case 60:
671 ptr2 = LtEntity(ptr2);
672 break;
673 case 62:
674 ptr2 = GtEntity(ptr2);
675 break;
676 case 9:
677 case 34:
678 case 39:
679 *ptr2 = (byte)num;
680 ptr2++;
681 break;
682 case 10:
683 if (_newLineHandling == NewLineHandling.Replace)
684 {
686 break;
687 }
688 *ptr2 = (byte)num;
689 ptr2++;
690 break;
691 case 13:
692 switch (_newLineHandling)
693 {
694 case NewLineHandling.Replace:
695 if (pSrc + 1 < pSrcEnd && pSrc[1] == '\n')
696 {
697 pSrc++;
698 }
700 break;
701 case NewLineHandling.Entitize:
703 break;
704 case NewLineHandling.None:
705 *ptr2 = (byte)num;
706 ptr2++;
707 break;
708 }
709 break;
710 default:
711 if (XmlCharType.IsSurrogate(num))
712 {
714 pSrc += 2;
715 }
716 else if (num <= 127 || num >= 65534)
717 {
718 ptr2 = InvalidXmlChar(num, ptr2, entitize: true);
719 pSrc++;
720 }
721 else
722 {
724 pSrc++;
725 }
726 continue;
727 }
728 pSrc++;
729 }
730 _bufPos = (int)(ptr2 - ptr);
732 _contentPos = 0;
733 }
734 }
735
736 protected unsafe void RawText(string s)
737 {
738 fixed (char* ptr = s)
739 {
740 RawText(ptr, ptr + s.Length);
741 }
742 }
743
744 protected unsafe void RawText(char* pSrcBegin, char* pSrcEnd)
745 {
746 fixed (byte* ptr = _bufBytes)
747 {
748 byte* ptr2 = ptr + _bufPos;
749 char* ptr3 = pSrcBegin;
750 int num = 0;
751 while (true)
752 {
753 byte* ptr4 = ptr2 + (pSrcEnd - ptr3);
754 if (ptr4 > ptr + _bufLen)
755 {
756 ptr4 = ptr + _bufLen;
757 }
758 for (; ptr2 < ptr4; ptr2++)
759 {
760 if ((num = *ptr3) > 127)
761 {
762 break;
763 }
764 ptr3++;
765 *ptr2 = (byte)num;
766 }
767 if (ptr3 >= pSrcEnd)
768 {
769 break;
770 }
771 if (ptr2 >= ptr4)
772 {
773 _bufPos = (int)(ptr2 - ptr);
774 FlushBuffer();
775 ptr2 = ptr + 1;
776 }
777 else if (XmlCharType.IsSurrogate(num))
778 {
780 ptr3 += 2;
781 }
782 else if (num <= 127 || num >= 65534)
783 {
784 ptr2 = InvalidXmlChar(num, ptr2, entitize: false);
785 ptr3++;
786 }
787 else
788 {
790 ptr3++;
791 }
792 }
793 _bufPos = (int)(ptr2 - ptr);
794 }
795 }
796
797 protected unsafe void WriteRawWithCharChecking(char* pSrcBegin, char* pSrcEnd)
798 {
799 fixed (byte* ptr2 = _bufBytes)
800 {
801 char* ptr = pSrcBegin;
802 byte* ptr3 = ptr2 + _bufPos;
803 int num = 0;
804 while (true)
805 {
806 byte* ptr4 = ptr3 + (pSrcEnd - ptr);
807 if (ptr4 > ptr2 + _bufLen)
808 {
809 ptr4 = ptr2 + _bufLen;
810 }
811 while (ptr3 < ptr4 && XmlCharType.IsTextChar((char)(num = *ptr)) && num <= 127)
812 {
813 *ptr3 = (byte)num;
814 ptr3++;
815 ptr++;
816 }
817 if (ptr >= pSrcEnd)
818 {
819 break;
820 }
821 if (ptr3 >= ptr4)
822 {
823 _bufPos = (int)(ptr3 - ptr2);
824 FlushBuffer();
825 ptr3 = ptr2 + 1;
826 continue;
827 }
828 switch (num)
829 {
830 case 9:
831 case 38:
832 case 60:
833 case 93:
834 *ptr3 = (byte)num;
835 ptr3++;
836 break;
837 case 13:
838 if (_newLineHandling == NewLineHandling.Replace)
839 {
840 if (ptr + 1 < pSrcEnd && ptr[1] == '\n')
841 {
842 ptr++;
843 }
845 }
846 else
847 {
848 *ptr3 = (byte)num;
849 ptr3++;
850 }
851 break;
852 case 10:
853 if (_newLineHandling == NewLineHandling.Replace)
854 {
856 break;
857 }
858 *ptr3 = (byte)num;
859 ptr3++;
860 break;
861 default:
862 if (XmlCharType.IsSurrogate(num))
863 {
865 ptr += 2;
866 }
867 else if (num <= 127 || num >= 65534)
868 {
869 ptr3 = InvalidXmlChar(num, ptr3, entitize: false);
870 ptr++;
871 }
872 else
873 {
875 ptr++;
876 }
877 continue;
878 }
879 ptr++;
880 }
881 _bufPos = (int)(ptr3 - ptr2);
882 }
883 }
884
885 protected unsafe void WriteCommentOrPi(string text, int stopChar)
886 {
887 if (text.Length == 0)
888 {
889 if (_bufPos >= _bufLen)
890 {
891 FlushBuffer();
892 }
893 return;
894 }
895 fixed (char* ptr2 = text)
896 {
897 byte[] bufBytes = _bufBytes;
898 fixed (byte[] array = bufBytes)
899 {
900 byte* ptr = (byte*)((bufBytes != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
901 char* ptr3 = ptr2;
902 char* ptr4 = ptr2 + text.Length;
903 byte* ptr5 = ptr + _bufPos;
904 int num = 0;
905 while (true)
906 {
907 byte* ptr6 = ptr5 + (ptr4 - ptr3);
908 if (ptr6 > ptr + _bufLen)
909 {
910 ptr6 = ptr + _bufLen;
911 }
912 while (ptr5 < ptr6 && XmlCharType.IsTextChar((char)(num = *ptr3)) && num != stopChar && num <= 127)
913 {
914 *ptr5 = (byte)num;
915 ptr5++;
916 ptr3++;
917 }
918 if (ptr3 >= ptr4)
919 {
920 break;
921 }
922 if (ptr5 >= ptr6)
923 {
924 _bufPos = (int)(ptr5 - ptr);
925 FlushBuffer();
926 ptr5 = ptr + 1;
927 continue;
928 }
929 switch (num)
930 {
931 case 45:
932 *ptr5 = 45;
933 ptr5++;
934 if (num == stopChar && (ptr3 + 1 == ptr4 || ptr3[1] == '-'))
935 {
936 *ptr5 = 32;
937 ptr5++;
938 }
939 break;
940 case 63:
941 *ptr5 = 63;
942 ptr5++;
943 if (num == stopChar && ptr3 + 1 < ptr4 && ptr3[1] == '>')
944 {
945 *ptr5 = 32;
946 ptr5++;
947 }
948 break;
949 case 93:
950 *ptr5 = 93;
951 ptr5++;
952 break;
953 case 13:
954 if (_newLineHandling == NewLineHandling.Replace)
955 {
956 if (ptr3 + 1 < ptr4 && ptr3[1] == '\n')
957 {
958 ptr3++;
959 }
961 }
962 else
963 {
964 *ptr5 = (byte)num;
965 ptr5++;
966 }
967 break;
968 case 10:
969 if (_newLineHandling == NewLineHandling.Replace)
970 {
972 break;
973 }
974 *ptr5 = (byte)num;
975 ptr5++;
976 break;
977 case 9:
978 case 38:
979 case 60:
980 *ptr5 = (byte)num;
981 ptr5++;
982 break;
983 default:
984 if (XmlCharType.IsSurrogate(num))
985 {
987 ptr3 += 2;
988 }
989 else if (num <= 127 || num >= 65534)
990 {
991 ptr5 = InvalidXmlChar(num, ptr5, entitize: false);
992 ptr3++;
993 }
994 else
995 {
997 ptr3++;
998 }
999 continue;
1000 }
1001 ptr3++;
1002 }
1003 _bufPos = (int)(ptr5 - ptr);
1004 }
1005 }
1006 }
1007
1008 protected unsafe void WriteCDataSection(string text)
1009 {
1010 if (text.Length == 0)
1011 {
1012 if (_bufPos >= _bufLen)
1013 {
1014 FlushBuffer();
1015 }
1016 return;
1017 }
1018 fixed (char* ptr2 = text)
1019 {
1020 byte[] bufBytes = _bufBytes;
1021 fixed (byte[] array = bufBytes)
1022 {
1023 byte* ptr = (byte*)((bufBytes != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
1024 char* ptr3 = ptr2;
1025 char* ptr4 = ptr2 + text.Length;
1026 byte* ptr5 = ptr + _bufPos;
1027 int num = 0;
1028 while (true)
1029 {
1030 byte* ptr6 = ptr5 + (ptr4 - ptr3);
1031 if (ptr6 > ptr + _bufLen)
1032 {
1033 ptr6 = ptr + _bufLen;
1034 }
1035 while (ptr5 < ptr6 && XmlCharType.IsAttributeValueChar((char)(num = *ptr3)) && num != 93 && num <= 127)
1036 {
1037 *ptr5 = (byte)num;
1038 ptr5++;
1039 ptr3++;
1040 }
1041 if (ptr3 >= ptr4)
1042 {
1043 break;
1044 }
1045 if (ptr5 >= ptr6)
1046 {
1047 _bufPos = (int)(ptr5 - ptr);
1048 FlushBuffer();
1049 ptr5 = ptr + 1;
1050 continue;
1051 }
1052 switch (num)
1053 {
1054 case 62:
1055 if (_hadDoubleBracket && ptr5[-1] == 93)
1056 {
1059 }
1060 *ptr5 = 62;
1061 ptr5++;
1062 break;
1063 case 93:
1064 if (ptr5[-1] == 93)
1065 {
1066 _hadDoubleBracket = true;
1067 }
1068 else
1069 {
1070 _hadDoubleBracket = false;
1071 }
1072 *ptr5 = 93;
1073 ptr5++;
1074 break;
1075 case 13:
1076 if (_newLineHandling == NewLineHandling.Replace)
1077 {
1078 if (ptr3 + 1 < ptr4 && ptr3[1] == '\n')
1079 {
1080 ptr3++;
1081 }
1083 }
1084 else
1085 {
1086 *ptr5 = (byte)num;
1087 ptr5++;
1088 }
1089 break;
1090 case 10:
1091 if (_newLineHandling == NewLineHandling.Replace)
1092 {
1094 break;
1095 }
1096 *ptr5 = (byte)num;
1097 ptr5++;
1098 break;
1099 case 9:
1100 case 34:
1101 case 38:
1102 case 39:
1103 case 60:
1104 *ptr5 = (byte)num;
1105 ptr5++;
1106 break;
1107 default:
1108 if (XmlCharType.IsSurrogate(num))
1109 {
1111 ptr3 += 2;
1112 }
1113 else if (num <= 127 || num >= 65534)
1114 {
1115 ptr5 = InvalidXmlChar(num, ptr5, entitize: false);
1116 ptr3++;
1117 }
1118 else
1119 {
1121 ptr3++;
1122 }
1123 continue;
1124 }
1125 ptr3++;
1126 }
1127 _bufPos = (int)(ptr5 - ptr);
1128 }
1129 }
1130 }
1131
1132 private static bool IsSurrogateByte(byte b)
1133 {
1134 return (b & 0xF8) == 240;
1135 }
1136
1137 private unsafe static byte* EncodeSurrogate(char* pSrc, char* pSrcEnd, byte* pDst)
1138 {
1139 int num = *pSrc;
1140 if (num <= 56319)
1141 {
1142 if (pSrc + 1 < pSrcEnd)
1143 {
1144 int num2 = pSrc[1];
1146 {
1148 *pDst = (byte)(0xF0u | (uint)(num >> 18));
1149 pDst[1] = (byte)(0x80u | ((uint)(num >> 12) & 0x3Fu));
1150 pDst[2] = (byte)(0x80u | ((uint)(num >> 6) & 0x3Fu));
1151 pDst[3] = (byte)(0x80u | ((uint)num & 0x3Fu));
1152 pDst += 4;
1153 return pDst;
1154 }
1155 throw XmlConvert.CreateInvalidSurrogatePairException((char)num2, (char)num);
1156 }
1158 }
1160 }
1161
1162 private unsafe byte* InvalidXmlChar(int ch, byte* pDst, bool entitize)
1163 {
1164 if (_checkCharacters)
1165 {
1166 throw XmlConvert.CreateInvalidCharException((char)ch, '\0');
1167 }
1168 if (entitize)
1169 {
1170 return CharEntity(pDst, (char)ch);
1171 }
1172 if (ch < 128)
1173 {
1174 *pDst = (byte)ch;
1175 pDst++;
1176 }
1177 else
1178 {
1180 }
1181 return pDst;
1182 }
1183
1184 internal unsafe void EncodeChar(ref char* pSrc, char* pSrcEnd, ref byte* pDst)
1185 {
1186 int num = *pSrc;
1187 if (XmlCharType.IsSurrogate(num))
1188 {
1190 pSrc += 2;
1191 }
1192 else if (num <= 127 || num >= 65534)
1193 {
1194 pDst = InvalidXmlChar(num, pDst, entitize: false);
1195 pSrc++;
1196 }
1197 else
1198 {
1200 pSrc++;
1201 }
1202 }
1203
1204 internal unsafe static byte* EncodeMultibyteUTF8(int ch, byte* pDst)
1205 {
1206 if (ch < 2048)
1207 {
1208 *pDst = (byte)(0xFFFFFFC0u | (uint)(ch >> 6));
1209 }
1210 else
1211 {
1212 *pDst = (byte)(0xFFFFFFE0u | (uint)(ch >> 12));
1213 pDst++;
1214 *pDst = (byte)(0xFFFFFF80u | ((uint)(ch >> 6) & 0x3Fu));
1215 }
1216 pDst++;
1217 *pDst = (byte)(0x80u | ((uint)ch & 0x3Fu));
1218 return pDst + 1;
1219 }
1220
1221 internal unsafe static void CharToUTF8(ref char* pSrc, char* pSrcEnd, ref byte* pDst)
1222 {
1223 int num = *pSrc;
1224 if (num <= 127)
1225 {
1226 *pDst = (byte)num;
1227 pDst++;
1228 pSrc++;
1229 }
1230 else if (XmlCharType.IsSurrogate(num))
1231 {
1233 pSrc += 2;
1234 }
1235 else
1236 {
1238 pSrc++;
1239 }
1240 }
1241
1242 protected unsafe byte* WriteNewLine(byte* pDst)
1243 {
1244 fixed (byte* ptr = _bufBytes)
1245 {
1246 _bufPos = (int)(pDst - ptr);
1248 return ptr + _bufPos;
1249 }
1250 }
1251
1252 protected unsafe static byte* LtEntity(byte* pDst)
1253 {
1254 *pDst = 38;
1255 pDst[1] = 108;
1256 pDst[2] = 116;
1257 pDst[3] = 59;
1258 return pDst + 4;
1259 }
1260
1261 protected unsafe static byte* GtEntity(byte* pDst)
1262 {
1263 *pDst = 38;
1264 pDst[1] = 103;
1265 pDst[2] = 116;
1266 pDst[3] = 59;
1267 return pDst + 4;
1268 }
1269
1270 protected unsafe static byte* AmpEntity(byte* pDst)
1271 {
1272 *pDst = 38;
1273 pDst[1] = 97;
1274 pDst[2] = 109;
1275 pDst[3] = 112;
1276 pDst[4] = 59;
1277 return pDst + 5;
1278 }
1279
1280 protected unsafe static byte* QuoteEntity(byte* pDst)
1281 {
1282 *pDst = 38;
1283 pDst[1] = 113;
1284 pDst[2] = 117;
1285 pDst[3] = 111;
1286 pDst[4] = 116;
1287 pDst[5] = 59;
1288 return pDst + 6;
1289 }
1290
1291 protected unsafe static byte* TabEntity(byte* pDst)
1292 {
1293 *pDst = 38;
1294 pDst[1] = 35;
1295 pDst[2] = 120;
1296 pDst[3] = 57;
1297 pDst[4] = 59;
1298 return pDst + 5;
1299 }
1300
1301 protected unsafe static byte* LineFeedEntity(byte* pDst)
1302 {
1303 *pDst = 38;
1304 pDst[1] = 35;
1305 pDst[2] = 120;
1306 pDst[3] = 65;
1307 pDst[4] = 59;
1308 return pDst + 5;
1309 }
1310
1311 protected unsafe static byte* CarriageReturnEntity(byte* pDst)
1312 {
1313 *pDst = 38;
1314 pDst[1] = 35;
1315 pDst[2] = 120;
1316 pDst[3] = 68;
1317 pDst[4] = 59;
1318 return pDst + 5;
1319 }
1320
1321 private unsafe static byte* CharEntity(byte* pDst, char ch)
1322 {
1323 int num = ch;
1324 string text = num.ToString("X", NumberFormatInfo.InvariantInfo);
1325 *pDst = 38;
1326 pDst[1] = 35;
1327 pDst[2] = 120;
1328 pDst += 3;
1329 fixed (char* ptr = text)
1330 {
1331 char* ptr2 = ptr;
1332 while ((*(pDst++) = (byte)(*(ptr2++))) != 0)
1333 {
1334 }
1335 }
1336 pDst[-1] = 59;
1337 return pDst;
1338 }
1339
1340 protected unsafe static byte* RawStartCData(byte* pDst)
1341 {
1342 *pDst = 60;
1343 pDst[1] = 33;
1344 pDst[2] = 91;
1345 pDst[3] = 67;
1346 pDst[4] = 68;
1347 pDst[5] = 65;
1348 pDst[6] = 84;
1349 pDst[7] = 65;
1350 pDst[8] = 91;
1351 return pDst + 9;
1352 }
1353
1354 protected unsafe static byte* RawEndCData(byte* pDst)
1355 {
1356 *pDst = 93;
1357 pDst[1] = 93;
1358 pDst[2] = 62;
1359 return pDst + 3;
1360 }
1361
1362 protected void ValidateContentChars(string chars, string propertyName, bool allowOnlyWhitespace)
1363 {
1365 {
1367 {
1369 }
1370 return;
1371 }
1372 string text = null;
1373 int num = 0;
1374 object[] args;
1375 while (true)
1376 {
1377 if (num >= chars.Length)
1378 {
1379 return;
1380 }
1381 if (!XmlCharType.IsTextChar(chars[num]))
1382 {
1383 switch (chars[num])
1384 {
1385 case '&':
1386 case '<':
1387 case ']':
1388 {
1392 break;
1393 }
1394 default:
1396 {
1397 if (num + 1 < chars.Length && XmlCharType.IsLowSurrogate(chars[num + 1]))
1398 {
1399 num++;
1400 goto IL_00f6;
1401 }
1403 }
1404 else
1405 {
1406 if (!XmlCharType.IsLowSurrogate(chars[num]))
1407 {
1408 goto IL_00f6;
1409 }
1411 }
1412 break;
1413 case '\t':
1414 case '\n':
1415 case '\r':
1416 goto IL_00f6;
1417 }
1418 break;
1419 }
1420 goto IL_00f6;
1421 IL_00f6:
1422 num++;
1423 }
1425 args = new string[2] { propertyName, text };
1427 }
1428
1429 protected void CheckAsyncCall()
1430 {
1431 if (!_useAsync)
1432 {
1434 }
1435 }
1436
1438 {
1441 {
1442 await RawTextAsync("<?xml version=\"").ConfigureAwait(continueOnCapturedContext: false);
1444 if (_encoding != null)
1445 {
1448 }
1449 if (standalone != 0)
1450 {
1451 await RawTextAsync("\" standalone=\"").ConfigureAwait(continueOnCapturedContext: false);
1452 await RawTextAsync((standalone == XmlStandalone.Yes) ? "yes" : "no").ConfigureAwait(continueOnCapturedContext: false);
1453 }
1455 }
1456 }
1457
1458 internal override Task WriteXmlDeclarationAsync(string xmldecl)
1459 {
1462 {
1464 }
1465 return Task.CompletedTask;
1466 }
1467
1468 protected override async ValueTask DisposeAsyncCore()
1469 {
1470 try
1471 {
1473 }
1474 finally
1475 {
1476 _writeToNull = true;
1477 if (_stream != null)
1478 {
1479 try
1480 {
1482 }
1483 finally
1484 {
1485 try
1486 {
1487 if (_closeOutput)
1488 {
1490 }
1491 }
1492 finally
1493 {
1494 _stream = null;
1495 }
1496 }
1497 }
1498 }
1499 }
1500
1501 public override async Task WriteDocTypeAsync(string name, string pubid, string sysid, string subset)
1502 {
1506 if (pubid != null)
1507 {
1511 if (sysid != null)
1512 {
1514 }
1515 _bufBytes[_bufPos++] = 34;
1516 }
1517 else if (sysid != null)
1518 {
1521 _bufBytes[_bufPos++] = 34;
1522 }
1523 else
1524 {
1525 _bufBytes[_bufPos++] = 32;
1526 }
1527 if (subset != null)
1528 {
1529 _bufBytes[_bufPos++] = 91;
1531 _bufBytes[_bufPos++] = 93;
1532 }
1533 _bufBytes[_bufPos++] = 62;
1534 }
1535
1536 public override Task WriteStartElementAsync(string prefix, string localName, string ns)
1537 {
1539 _bufBytes[_bufPos++] = 60;
1540 Task task = ((prefix == null || prefix.Length == 0) ? RawTextAsync(localName) : RawTextAsync(prefix, ":", localName));
1541 return task.CallVoidFuncWhenFinishAsync(delegate(XmlUtf8RawTextWriter thisRef)
1542 {
1543 thisRef.WriteStartElementAsync_SetAttEndPos();
1544 }, this);
1545 }
1546
1548 {
1550 }
1551
1552 internal override Task WriteEndElementAsync(string prefix, string localName, string ns)
1553 {
1555 if (_contentPos != _bufPos)
1556 {
1557 _bufBytes[_bufPos++] = 60;
1558 _bufBytes[_bufPos++] = 47;
1559 if (prefix != null && prefix.Length != 0)
1560 {
1561 return RawTextAsync(prefix, ":", localName, ">");
1562 }
1563 return RawTextAsync(localName, ">");
1564 }
1565 _bufPos--;
1566 _bufBytes[_bufPos++] = 32;
1567 _bufBytes[_bufPos++] = 47;
1568 _bufBytes[_bufPos++] = 62;
1569 return Task.CompletedTask;
1570 }
1571
1572 internal override Task WriteFullEndElementAsync(string prefix, string localName, string ns)
1573 {
1575 _bufBytes[_bufPos++] = 60;
1576 _bufBytes[_bufPos++] = 47;
1577 if (prefix != null && prefix.Length != 0)
1578 {
1579 return RawTextAsync(prefix, ":", localName, ">");
1580 }
1581 return RawTextAsync(localName, ">");
1582 }
1583
1584 protected internal override Task WriteStartAttributeAsync(string prefix, string localName, string ns)
1585 {
1587 if (_attrEndPos == _bufPos)
1588 {
1589 _bufBytes[_bufPos++] = 32;
1590 }
1591 Task task = ((prefix == null || prefix.Length <= 0) ? RawTextAsync(localName) : RawTextAsync(prefix, ":", localName));
1592 return task.CallVoidFuncWhenFinishAsync(delegate(XmlUtf8RawTextWriter thisRef)
1593 {
1594 thisRef.WriteStartAttribute_SetInAttribute();
1595 }, this);
1596 }
1597
1599 {
1600 _bufBytes[_bufPos++] = 61;
1601 _bufBytes[_bufPos++] = 34;
1602 _inAttributeValue = true;
1603 }
1604
1605 protected internal override Task WriteEndAttributeAsync()
1606 {
1608 _bufBytes[_bufPos++] = 34;
1609 _inAttributeValue = false;
1611 return Task.CompletedTask;
1612 }
1613
1621
1623 {
1625 if (prefix.Length == 0)
1626 {
1628 }
1629 else
1630 {
1633 _bufBytes[_bufPos++] = 61;
1634 _bufBytes[_bufPos++] = 34;
1635 }
1636 _inAttributeValue = true;
1637 }
1638
1640 {
1642 _inAttributeValue = false;
1643 _bufBytes[_bufPos++] = 34;
1645 return Task.CompletedTask;
1646 }
1647
1648 public override async Task WriteCDataAsync(string text)
1649 {
1652 {
1653 _bufPos -= 3;
1654 }
1655 else
1656 {
1657 _bufBytes[_bufPos++] = 60;
1658 _bufBytes[_bufPos++] = 33;
1659 _bufBytes[_bufPos++] = 91;
1660 _bufBytes[_bufPos++] = 67;
1661 _bufBytes[_bufPos++] = 68;
1662 _bufBytes[_bufPos++] = 65;
1663 _bufBytes[_bufPos++] = 84;
1664 _bufBytes[_bufPos++] = 65;
1665 _bufBytes[_bufPos++] = 91;
1666 }
1668 _bufBytes[_bufPos++] = 93;
1669 _bufBytes[_bufPos++] = 93;
1670 _bufBytes[_bufPos++] = 62;
1671 _textPos = _bufPos;
1673 }
1674
1675 public override async Task WriteCommentAsync(string text)
1676 {
1678 _bufBytes[_bufPos++] = 60;
1679 _bufBytes[_bufPos++] = 33;
1680 _bufBytes[_bufPos++] = 45;
1681 _bufBytes[_bufPos++] = 45;
1683 _bufBytes[_bufPos++] = 45;
1684 _bufBytes[_bufPos++] = 45;
1685 _bufBytes[_bufPos++] = 62;
1686 }
1687
1688 public override async Task WriteProcessingInstructionAsync(string name, string text)
1689 {
1691 _bufBytes[_bufPos++] = 60;
1692 _bufBytes[_bufPos++] = 63;
1694 if (text.Length > 0)
1695 {
1696 _bufBytes[_bufPos++] = 32;
1698 }
1699 _bufBytes[_bufPos++] = 63;
1700 _bufBytes[_bufPos++] = 62;
1701 }
1702
1703 public override async Task WriteEntityRefAsync(string name)
1704 {
1706 _bufBytes[_bufPos++] = 38;
1708 _bufBytes[_bufPos++] = 59;
1709 if (_bufPos > _bufLen)
1710 {
1712 }
1713 _textPos = _bufPos;
1714 }
1715
1716 public override async Task WriteCharEntityAsync(char ch)
1717 {
1719 int num = ch;
1720 string text = num.ToString("X", NumberFormatInfo.InvariantInfo);
1722 {
1724 }
1725 _bufBytes[_bufPos++] = 38;
1726 _bufBytes[_bufPos++] = 35;
1727 _bufBytes[_bufPos++] = 120;
1729 _bufBytes[_bufPos++] = 59;
1730 if (_bufPos > _bufLen)
1731 {
1733 }
1734 _textPos = _bufPos;
1735 }
1736
1737 public override Task WriteWhitespaceAsync(string ws)
1738 {
1741 {
1743 }
1745 }
1746
1747 public override Task WriteStringAsync(string text)
1748 {
1751 {
1753 }
1755 }
1756
1758 {
1761 _bufBytes[_bufPos++] = 38;
1762 _bufBytes[_bufPos++] = 35;
1763 _bufBytes[_bufPos++] = 120;
1765 _bufBytes[_bufPos++] = 59;
1766 _textPos = _bufPos;
1767 }
1768
1769 public override Task WriteCharsAsync(char[] buffer, int index, int count)
1770 {
1773 {
1775 }
1777 }
1778
1785
1786 public override async Task WriteRawAsync(string data)
1787 {
1790 _textPos = _bufPos;
1791 }
1792
1793 public override async Task FlushAsync()
1794 {
1797 if (_stream != null)
1798 {
1800 }
1801 }
1802
1803 protected virtual async Task FlushBufferAsync()
1804 {
1805 try
1806 {
1807 if (!_writeToNull && _bufPos - 1 > 0)
1808 {
1810 }
1811 }
1812 catch
1813 {
1814 _writeToNull = true;
1815 throw;
1816 }
1817 finally
1818 {
1819 _bufBytes[0] = _bufBytes[_bufPos - 1];
1820 if (IsSurrogateByte(_bufBytes[0]))
1821 {
1823 _bufBytes[2] = _bufBytes[_bufPos + 1];
1824 _bufBytes[3] = _bufBytes[_bufPos + 2];
1825 }
1826 _textPos = ((_textPos == _bufPos) ? 1 : 0);
1827 _attrEndPos = ((_attrEndPos == _bufPos) ? 1 : 0);
1828 _contentPos = 0;
1829 _cdataPos = 0;
1830 _bufPos = 1;
1831 }
1832 }
1833
1834 protected unsafe int WriteAttributeTextBlockNoFlush(char* pSrc, char* pSrcEnd)
1835 {
1836 char* ptr = pSrc;
1837 fixed (byte* ptr2 = _bufBytes)
1838 {
1839 byte* ptr3 = ptr2 + _bufPos;
1840 int num = 0;
1841 while (true)
1842 {
1843 byte* ptr4 = ptr3 + (pSrcEnd - pSrc);
1844 if (ptr4 > ptr2 + _bufLen)
1845 {
1846 ptr4 = ptr2 + _bufLen;
1847 }
1848 while (ptr3 < ptr4 && XmlCharType.IsAttributeValueChar((char)(num = *pSrc)) && num <= 127)
1849 {
1850 *ptr3 = (byte)num;
1851 ptr3++;
1852 pSrc++;
1853 }
1854 if (pSrc >= pSrcEnd)
1855 {
1856 break;
1857 }
1858 if (ptr3 >= ptr4)
1859 {
1860 _bufPos = (int)(ptr3 - ptr2);
1861 return (int)(pSrc - ptr);
1862 }
1863 switch (num)
1864 {
1865 case 38:
1866 ptr3 = AmpEntity(ptr3);
1867 break;
1868 case 60:
1869 ptr3 = LtEntity(ptr3);
1870 break;
1871 case 62:
1872 ptr3 = GtEntity(ptr3);
1873 break;
1874 case 34:
1876 break;
1877 case 39:
1878 *ptr3 = (byte)num;
1879 ptr3++;
1880 break;
1881 case 9:
1883 {
1884 *ptr3 = (byte)num;
1885 ptr3++;
1886 }
1887 else
1888 {
1889 ptr3 = TabEntity(ptr3);
1890 }
1891 break;
1892 case 13:
1894 {
1895 *ptr3 = (byte)num;
1896 ptr3++;
1897 }
1898 else
1899 {
1901 }
1902 break;
1903 case 10:
1905 {
1906 *ptr3 = (byte)num;
1907 ptr3++;
1908 }
1909 else
1910 {
1912 }
1913 break;
1914 default:
1915 if (XmlCharType.IsSurrogate(num))
1916 {
1918 pSrc += 2;
1919 }
1920 else if (num <= 127 || num >= 65534)
1921 {
1922 ptr3 = InvalidXmlChar(num, ptr3, entitize: true);
1923 pSrc++;
1924 }
1925 else
1926 {
1928 pSrc++;
1929 }
1930 continue;
1931 }
1932 pSrc++;
1933 }
1934 _bufPos = (int)(ptr3 - ptr2);
1935 }
1936 return -1;
1937 }
1938
1939 protected unsafe int WriteAttributeTextBlockNoFlush(char[] chars, int index, int count)
1940 {
1941 if (count == 0)
1942 {
1943 return -1;
1944 }
1945 fixed (char* ptr = &chars[index])
1946 {
1947 char* ptr2 = ptr;
1948 char* pSrcEnd = ptr2 + count;
1950 }
1951 }
1952
1953 protected unsafe int WriteAttributeTextBlockNoFlush(string text, int index, int count)
1954 {
1955 if (count == 0)
1956 {
1957 return -1;
1958 }
1959 fixed (char* ptr = text)
1960 {
1961 char* ptr2 = ptr + index;
1962 char* pSrcEnd = ptr2 + count;
1964 }
1965 }
1966
1968 {
1969 int curIndex = index;
1970 int leftCount = count;
1971 int writeLen;
1972 do
1973 {
1975 curIndex += writeLen;
1977 if (writeLen >= 0)
1978 {
1980 }
1981 }
1982 while (writeLen >= 0);
1983 }
1984
1986 {
1987 int num = 0;
1988 int num2 = 0;
1989 int length = text.Length;
1991 num2 += num;
1992 length -= num;
1993 if (num >= 0)
1994 {
1996 }
1997 return Task.CompletedTask;
1998 }
1999
2001 {
2003 int writeLen;
2004 do
2005 {
2007 curIndex += writeLen;
2009 if (writeLen >= 0)
2010 {
2012 }
2013 }
2014 while (writeLen >= 0);
2015 }
2016
2017 protected unsafe int WriteElementTextBlockNoFlush(char* pSrc, char* pSrcEnd, out bool needWriteNewLine)
2018 {
2019 needWriteNewLine = false;
2020 char* ptr = pSrc;
2021 fixed (byte* ptr2 = _bufBytes)
2022 {
2023 byte* ptr3 = ptr2 + _bufPos;
2024 int num = 0;
2025 while (true)
2026 {
2027 byte* ptr4 = ptr3 + (pSrcEnd - pSrc);
2028 if (ptr4 > ptr2 + _bufLen)
2029 {
2030 ptr4 = ptr2 + _bufLen;
2031 }
2032 while (ptr3 < ptr4 && XmlCharType.IsAttributeValueChar((char)(num = *pSrc)) && num <= 127)
2033 {
2034 *ptr3 = (byte)num;
2035 ptr3++;
2036 pSrc++;
2037 }
2038 if (pSrc >= pSrcEnd)
2039 {
2040 break;
2041 }
2042 if (ptr3 >= ptr4)
2043 {
2044 _bufPos = (int)(ptr3 - ptr2);
2045 return (int)(pSrc - ptr);
2046 }
2047 switch (num)
2048 {
2049 case 38:
2050 ptr3 = AmpEntity(ptr3);
2051 break;
2052 case 60:
2053 ptr3 = LtEntity(ptr3);
2054 break;
2055 case 62:
2056 ptr3 = GtEntity(ptr3);
2057 break;
2058 case 9:
2059 case 34:
2060 case 39:
2061 *ptr3 = (byte)num;
2062 ptr3++;
2063 break;
2064 case 10:
2065 if (_newLineHandling == NewLineHandling.Replace)
2066 {
2067 _bufPos = (int)(ptr3 - ptr2);
2068 needWriteNewLine = true;
2069 return (int)(pSrc - ptr);
2070 }
2071 *ptr3 = (byte)num;
2072 ptr3++;
2073 break;
2074 case 13:
2075 switch (_newLineHandling)
2076 {
2077 case NewLineHandling.Replace:
2078 if (pSrc + 1 < pSrcEnd && pSrc[1] == '\n')
2079 {
2080 pSrc++;
2081 }
2082 _bufPos = (int)(ptr3 - ptr2);
2083 needWriteNewLine = true;
2084 return (int)(pSrc - ptr);
2085 case NewLineHandling.Entitize:
2087 break;
2088 case NewLineHandling.None:
2089 *ptr3 = (byte)num;
2090 ptr3++;
2091 break;
2092 }
2093 break;
2094 default:
2095 if (XmlCharType.IsSurrogate(num))
2096 {
2098 pSrc += 2;
2099 }
2100 else if (num <= 127 || num >= 65534)
2101 {
2102 ptr3 = InvalidXmlChar(num, ptr3, entitize: true);
2103 pSrc++;
2104 }
2105 else
2106 {
2108 pSrc++;
2109 }
2110 continue;
2111 }
2112 pSrc++;
2113 }
2114 _bufPos = (int)(ptr3 - ptr2);
2115 _textPos = _bufPos;
2116 _contentPos = 0;
2117 }
2118 return -1;
2119 }
2120
2121 protected unsafe int WriteElementTextBlockNoFlush(char[] chars, int index, int count, out bool needWriteNewLine)
2122 {
2123 needWriteNewLine = false;
2124 if (count == 0)
2125 {
2126 _contentPos = 0;
2127 return -1;
2128 }
2129 fixed (char* ptr = &chars[index])
2130 {
2131 char* ptr2 = ptr;
2132 char* pSrcEnd = ptr2 + count;
2134 }
2135 }
2136
2137 protected unsafe int WriteElementTextBlockNoFlush(string text, int index, int count, out bool needWriteNewLine)
2138 {
2139 needWriteNewLine = false;
2140 if (count == 0)
2141 {
2142 _contentPos = 0;
2143 return -1;
2144 }
2145 fixed (char* ptr = text)
2146 {
2147 char* ptr2 = ptr + index;
2148 char* pSrcEnd = ptr2 + count;
2150 }
2151 }
2152
2154 {
2155 int curIndex = index;
2156 int leftCount = count;
2157 bool needWriteNewLine = false;
2158 int writeLen;
2159 do
2160 {
2162 curIndex += writeLen;
2164 if (needWriteNewLine)
2165 {
2167 curIndex++;
2168 leftCount--;
2169 }
2170 else if (writeLen >= 0)
2171 {
2173 }
2174 }
2175 while (writeLen >= 0 || needWriteNewLine);
2176 }
2177
2179 {
2180 int num = 0;
2181 int num2 = 0;
2182 int length = text.Length;
2183 bool needWriteNewLine = false;
2185 num2 += num;
2186 length -= num;
2187 if (needWriteNewLine)
2188 {
2190 }
2191 if (num >= 0)
2192 {
2194 }
2195 return Task.CompletedTask;
2196 }
2197
2199 {
2200 bool needWriteNewLine = false;
2201 if (!newLine)
2202 {
2204 }
2205 else
2206 {
2208 curIndex++;
2209 leftCount--;
2210 }
2211 int writeLen;
2212 do
2213 {
2215 curIndex += writeLen;
2217 if (needWriteNewLine)
2218 {
2220 curIndex++;
2221 leftCount--;
2222 }
2223 else if (writeLen >= 0)
2224 {
2226 }
2227 }
2228 while (writeLen >= 0 || needWriteNewLine);
2229 }
2230
2231 protected unsafe int RawTextNoFlush(char* pSrcBegin, char* pSrcEnd)
2232 {
2233 fixed (byte* ptr = _bufBytes)
2234 {
2235 byte* ptr2 = ptr + _bufPos;
2236 char* ptr3 = pSrcBegin;
2237 int num = 0;
2238 while (true)
2239 {
2240 byte* ptr4 = ptr2 + (pSrcEnd - ptr3);
2241 if (ptr4 > ptr + _bufLen)
2242 {
2243 ptr4 = ptr + _bufLen;
2244 }
2245 for (; ptr2 < ptr4; ptr2++)
2246 {
2247 if ((num = *ptr3) > 127)
2248 {
2249 break;
2250 }
2251 ptr3++;
2252 *ptr2 = (byte)num;
2253 }
2254 if (ptr3 >= pSrcEnd)
2255 {
2256 break;
2257 }
2258 if (ptr2 >= ptr4)
2259 {
2260 _bufPos = (int)(ptr2 - ptr);
2261 return (int)(ptr3 - pSrcBegin);
2262 }
2263 if (XmlCharType.IsSurrogate(num))
2264 {
2266 ptr3 += 2;
2267 }
2268 else if (num <= 127 || num >= 65534)
2269 {
2270 ptr2 = InvalidXmlChar(num, ptr2, entitize: false);
2271 ptr3++;
2272 }
2273 else
2274 {
2276 ptr3++;
2277 }
2278 }
2279 _bufPos = (int)(ptr2 - ptr);
2280 }
2281 return -1;
2282 }
2283
2284 protected unsafe int RawTextNoFlush(string text, int index, int count)
2285 {
2286 if (count == 0)
2287 {
2288 return -1;
2289 }
2290 fixed (char* ptr = text)
2291 {
2292 char* ptr2 = ptr + index;
2293 char* pSrcEnd = ptr2 + count;
2294 return RawTextNoFlush(ptr2, pSrcEnd);
2295 }
2296 }
2297
2298 protected Task RawTextAsync(string text)
2299 {
2300 int num = RawTextNoFlush(text, 0, text.Length);
2301 if (num < 0)
2302 {
2303 return Task.CompletedTask;
2304 }
2305 return _RawTextAsync(text, num, text.Length - num);
2306 }
2307
2308 protected Task RawTextAsync(string text1, string text2 = null, string text3 = null, string text4 = null)
2309 {
2310 int num = RawTextNoFlush(text1, 0, text1.Length);
2311 if (num >= 0)
2312 {
2313 return _RawTextAsync(text1, num, text1.Length - num, text2, text3, text4);
2314 }
2315 if (text2 != null)
2316 {
2317 num = RawTextNoFlush(text2, 0, text2.Length);
2318 if (num >= 0)
2319 {
2320 return _RawTextAsync(text2, num, text2.Length - num, text3, text4);
2321 }
2322 }
2323 if (text3 != null)
2324 {
2325 num = RawTextNoFlush(text3, 0, text3.Length);
2326 if (num >= 0)
2327 {
2328 return _RawTextAsync(text3, num, text3.Length - num, text4);
2329 }
2330 }
2331 if (text4 != null)
2332 {
2333 num = RawTextNoFlush(text4, 0, text4.Length);
2334 if (num >= 0)
2335 {
2336 return _RawTextAsync(text4, num, text4.Length - num);
2337 }
2338 }
2339 return Task.CompletedTask;
2340 }
2341
2342 private async Task _RawTextAsync(string text1, int curIndex1, int leftCount1, string text2 = null, string text3 = null, string text4 = null)
2343 {
2345 int writeLen;
2346 do
2347 {
2351 if (writeLen >= 0)
2352 {
2354 }
2355 }
2356 while (writeLen >= 0);
2357 if (text2 != null)
2358 {
2360 }
2361 }
2362
2364 {
2365 needWriteNewLine = false;
2366 fixed (byte* ptr2 = _bufBytes)
2367 {
2368 char* ptr = pSrcBegin;
2369 byte* ptr3 = ptr2 + _bufPos;
2370 int num = 0;
2371 while (true)
2372 {
2373 byte* ptr4 = ptr3 + (pSrcEnd - ptr);
2374 if (ptr4 > ptr2 + _bufLen)
2375 {
2376 ptr4 = ptr2 + _bufLen;
2377 }
2378 while (ptr3 < ptr4 && XmlCharType.IsTextChar((char)(num = *ptr)) && num <= 127)
2379 {
2380 *ptr3 = (byte)num;
2381 ptr3++;
2382 ptr++;
2383 }
2384 if (ptr >= pSrcEnd)
2385 {
2386 break;
2387 }
2388 if (ptr3 >= ptr4)
2389 {
2390 _bufPos = (int)(ptr3 - ptr2);
2391 return (int)(ptr - pSrcBegin);
2392 }
2393 switch (num)
2394 {
2395 case 9:
2396 case 38:
2397 case 60:
2398 case 93:
2399 *ptr3 = (byte)num;
2400 ptr3++;
2401 break;
2402 case 13:
2403 if (_newLineHandling == NewLineHandling.Replace)
2404 {
2405 if (ptr + 1 < pSrcEnd && ptr[1] == '\n')
2406 {
2407 ptr++;
2408 }
2409 _bufPos = (int)(ptr3 - ptr2);
2410 needWriteNewLine = true;
2411 return (int)(ptr - pSrcBegin);
2412 }
2413 *ptr3 = (byte)num;
2414 ptr3++;
2415 break;
2416 case 10:
2417 if (_newLineHandling == NewLineHandling.Replace)
2418 {
2419 _bufPos = (int)(ptr3 - ptr2);
2420 needWriteNewLine = true;
2421 return (int)(ptr - pSrcBegin);
2422 }
2423 *ptr3 = (byte)num;
2424 ptr3++;
2425 break;
2426 default:
2427 if (XmlCharType.IsSurrogate(num))
2428 {
2430 ptr += 2;
2431 }
2432 else if (num <= 127 || num >= 65534)
2433 {
2434 ptr3 = InvalidXmlChar(num, ptr3, entitize: false);
2435 ptr++;
2436 }
2437 else
2438 {
2440 ptr++;
2441 }
2442 continue;
2443 }
2444 ptr++;
2445 }
2446 _bufPos = (int)(ptr3 - ptr2);
2447 }
2448 return -1;
2449 }
2450
2451 protected unsafe int WriteRawWithCharCheckingNoFlush(char[] chars, int index, int count, out bool needWriteNewLine)
2452 {
2453 needWriteNewLine = false;
2454 if (count == 0)
2455 {
2456 return -1;
2457 }
2458 fixed (char* ptr = &chars[index])
2459 {
2460 char* ptr2 = ptr;
2461 char* pSrcEnd = ptr2 + count;
2463 }
2464 }
2465
2466 protected unsafe int WriteRawWithCharCheckingNoFlush(string text, int index, int count, out bool needWriteNewLine)
2467 {
2468 needWriteNewLine = false;
2469 if (count == 0)
2470 {
2471 return -1;
2472 }
2473 fixed (char* ptr = text)
2474 {
2475 char* ptr2 = ptr + index;
2476 char* pSrcEnd = ptr2 + count;
2478 }
2479 }
2480
2482 {
2483 int curIndex = index;
2484 int leftCount = count;
2485 bool needWriteNewLine = false;
2486 int writeLen;
2487 do
2488 {
2490 curIndex += writeLen;
2492 if (needWriteNewLine)
2493 {
2495 curIndex++;
2496 leftCount--;
2497 }
2498 else if (writeLen >= 0)
2499 {
2501 }
2502 }
2503 while (writeLen >= 0 || needWriteNewLine);
2504 }
2505
2507 {
2508 int curIndex = 0;
2509 int leftCount = text.Length;
2510 bool needWriteNewLine = false;
2511 int writeLen;
2512 do
2513 {
2515 curIndex += writeLen;
2517 if (needWriteNewLine)
2518 {
2520 curIndex++;
2521 leftCount--;
2522 }
2523 else if (writeLen >= 0)
2524 {
2526 }
2527 }
2528 while (writeLen >= 0 || needWriteNewLine);
2529 }
2530
2531 protected unsafe int WriteCommentOrPiNoFlush(string text, int index, int count, int stopChar, out bool needWriteNewLine)
2532 {
2533 needWriteNewLine = false;
2534 if (count == 0)
2535 {
2536 return -1;
2537 }
2538 fixed (char* ptr = text)
2539 {
2540 char* ptr2 = ptr + index;
2541 byte[] bufBytes = _bufBytes;
2542 fixed (byte[] array = bufBytes)
2543 {
2544 byte* ptr3 = (byte*)((bufBytes != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
2545 char* ptr4 = ptr2;
2546 char* ptr5 = ptr4;
2547 char* ptr6 = ptr2 + count;
2548 byte* ptr7 = ptr3 + _bufPos;
2549 int num = 0;
2550 while (true)
2551 {
2552 byte* ptr8 = ptr7 + (ptr6 - ptr4);
2553 if (ptr8 > ptr3 + _bufLen)
2554 {
2555 ptr8 = ptr3 + _bufLen;
2556 }
2557 while (ptr7 < ptr8 && XmlCharType.IsTextChar((char)(num = *ptr4)) && num != stopChar && num <= 127)
2558 {
2559 *ptr7 = (byte)num;
2560 ptr7++;
2561 ptr4++;
2562 }
2563 if (ptr4 >= ptr6)
2564 {
2565 break;
2566 }
2567 if (ptr7 >= ptr8)
2568 {
2569 _bufPos = (int)(ptr7 - ptr3);
2570 return (int)(ptr4 - ptr5);
2571 }
2572 switch (num)
2573 {
2574 case 45:
2575 *ptr7 = 45;
2576 ptr7++;
2577 if (num == stopChar && (ptr4 + 1 == ptr6 || ptr4[1] == '-'))
2578 {
2579 *ptr7 = 32;
2580 ptr7++;
2581 }
2582 break;
2583 case 63:
2584 *ptr7 = 63;
2585 ptr7++;
2586 if (num == stopChar && ptr4 + 1 < ptr6 && ptr4[1] == '>')
2587 {
2588 *ptr7 = 32;
2589 ptr7++;
2590 }
2591 break;
2592 case 93:
2593 *ptr7 = 93;
2594 ptr7++;
2595 break;
2596 case 13:
2597 if (_newLineHandling == NewLineHandling.Replace)
2598 {
2599 if (ptr4 + 1 < ptr6 && ptr4[1] == '\n')
2600 {
2601 ptr4++;
2602 }
2603 _bufPos = (int)(ptr7 - ptr3);
2604 needWriteNewLine = true;
2605 return (int)(ptr4 - ptr5);
2606 }
2607 *ptr7 = (byte)num;
2608 ptr7++;
2609 break;
2610 case 10:
2611 if (_newLineHandling == NewLineHandling.Replace)
2612 {
2613 _bufPos = (int)(ptr7 - ptr3);
2614 needWriteNewLine = true;
2615 return (int)(ptr4 - ptr5);
2616 }
2617 *ptr7 = (byte)num;
2618 ptr7++;
2619 break;
2620 case 9:
2621 case 38:
2622 case 60:
2623 *ptr7 = (byte)num;
2624 ptr7++;
2625 break;
2626 default:
2627 if (XmlCharType.IsSurrogate(num))
2628 {
2630 ptr4 += 2;
2631 }
2632 else if (num <= 127 || num >= 65534)
2633 {
2634 ptr7 = InvalidXmlChar(num, ptr7, entitize: false);
2635 ptr4++;
2636 }
2637 else
2638 {
2640 ptr4++;
2641 }
2642 continue;
2643 }
2644 ptr4++;
2645 }
2646 _bufPos = (int)(ptr7 - ptr3);
2647 }
2648 return -1;
2649 }
2650 }
2651
2653 {
2654 if (text.Length == 0)
2655 {
2656 if (_bufPos >= _bufLen)
2657 {
2659 }
2660 return;
2661 }
2662 int curIndex = 0;
2663 int leftCount = text.Length;
2664 bool needWriteNewLine = false;
2665 int writeLen;
2666 do
2667 {
2669 curIndex += writeLen;
2671 if (needWriteNewLine)
2672 {
2674 curIndex++;
2675 leftCount--;
2676 }
2677 else if (writeLen >= 0)
2678 {
2680 }
2681 }
2682 while (writeLen >= 0 || needWriteNewLine);
2683 }
2684
2685 protected unsafe int WriteCDataSectionNoFlush(string text, int index, int count, out bool needWriteNewLine)
2686 {
2687 needWriteNewLine = false;
2688 if (count == 0)
2689 {
2690 return -1;
2691 }
2692 fixed (char* ptr = text)
2693 {
2694 char* ptr2 = ptr + index;
2695 byte[] bufBytes = _bufBytes;
2696 fixed (byte[] array = bufBytes)
2697 {
2698 byte* ptr3 = (byte*)((bufBytes != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
2699 char* ptr4 = ptr2;
2700 char* ptr5 = ptr2 + count;
2701 char* ptr6 = ptr4;
2702 byte* ptr7 = ptr3 + _bufPos;
2703 int num = 0;
2704 while (true)
2705 {
2706 byte* ptr8 = ptr7 + (ptr5 - ptr4);
2707 if (ptr8 > ptr3 + _bufLen)
2708 {
2709 ptr8 = ptr3 + _bufLen;
2710 }
2711 while (ptr7 < ptr8 && XmlCharType.IsAttributeValueChar((char)(num = *ptr4)) && num != 93 && num <= 127)
2712 {
2713 *ptr7 = (byte)num;
2714 ptr7++;
2715 ptr4++;
2716 }
2717 if (ptr4 >= ptr5)
2718 {
2719 break;
2720 }
2721 if (ptr7 >= ptr8)
2722 {
2723 _bufPos = (int)(ptr7 - ptr3);
2724 return (int)(ptr4 - ptr6);
2725 }
2726 switch (num)
2727 {
2728 case 62:
2729 if (_hadDoubleBracket && ptr7[-1] == 93)
2730 {
2733 }
2734 *ptr7 = 62;
2735 ptr7++;
2736 break;
2737 case 93:
2738 if (ptr7[-1] == 93)
2739 {
2740 _hadDoubleBracket = true;
2741 }
2742 else
2743 {
2744 _hadDoubleBracket = false;
2745 }
2746 *ptr7 = 93;
2747 ptr7++;
2748 break;
2749 case 13:
2750 if (_newLineHandling == NewLineHandling.Replace)
2751 {
2752 if (ptr4 + 1 < ptr5 && ptr4[1] == '\n')
2753 {
2754 ptr4++;
2755 }
2756 _bufPos = (int)(ptr7 - ptr3);
2757 needWriteNewLine = true;
2758 return (int)(ptr4 - ptr6);
2759 }
2760 *ptr7 = (byte)num;
2761 ptr7++;
2762 break;
2763 case 10:
2764 if (_newLineHandling == NewLineHandling.Replace)
2765 {
2766 _bufPos = (int)(ptr7 - ptr3);
2767 needWriteNewLine = true;
2768 return (int)(ptr4 - ptr6);
2769 }
2770 *ptr7 = (byte)num;
2771 ptr7++;
2772 break;
2773 case 9:
2774 case 34:
2775 case 38:
2776 case 39:
2777 case 60:
2778 *ptr7 = (byte)num;
2779 ptr7++;
2780 break;
2781 default:
2782 if (XmlCharType.IsSurrogate(num))
2783 {
2785 ptr4 += 2;
2786 }
2787 else if (num <= 127 || num >= 65534)
2788 {
2789 ptr7 = InvalidXmlChar(num, ptr7, entitize: false);
2790 ptr4++;
2791 }
2792 else
2793 {
2795 ptr4++;
2796 }
2797 continue;
2798 }
2799 ptr4++;
2800 }
2801 _bufPos = (int)(ptr7 - ptr3);
2802 }
2803 return -1;
2804 }
2805 }
2806
2808 {
2809 if (text.Length == 0)
2810 {
2811 if (_bufPos >= _bufLen)
2812 {
2814 }
2815 return;
2816 }
2817 int curIndex = 0;
2818 int leftCount = text.Length;
2819 bool needWriteNewLine = false;
2820 int writeLen;
2821 do
2822 {
2824 curIndex += writeLen;
2826 if (needWriteNewLine)
2827 {
2829 curIndex++;
2830 leftCount--;
2831 }
2832 else if (writeLen >= 0)
2833 {
2835 }
2836 }
2837 while (writeLen >= 0 || needWriteNewLine);
2838 }
2839}
static CultureInfo InvariantCulture
Task FlushAsync()
Definition Stream.cs:669
Task WriteAsync(byte[] buffer, int offset, int count)
Definition Stream.cs:914
void Dispose()
Definition Stream.cs:639
void Write(byte[] buffer, int offset, int count)
virtual ValueTask DisposeAsync()
Definition Stream.cs:654
static string Xml_IndentCharsNotWhitespace
Definition SR.cs:334
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Xml_InvalidCharsInIndent
Definition SR.cs:332
static string Xml_InvalidSurrogateHighChar
Definition SR.cs:322
static string Xml_InvalidSurrogateMissingLowChar
Definition SR.cs:324
static string Xml_InvalidCharacter
Definition SR.cs:110
static string Xml_WriterAsyncNotSetException
Definition SR.cs:284
Definition SR.cs:7
virtual ReadOnlySpan< byte > Preamble
Definition Encoding.cs:347
virtual string WebName
Definition Encoding.cs:386
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
static Task CompletedTask
Definition Task.cs:1120
static bool IsSurrogate(int ch)
static bool IsAttributeValueChar(char ch)
static bool IsOnlyWhitespace(string str)
static bool IsTextChar(char ch)
static bool IsLowSurrogate(int ch)
static int CombineSurrogateChar(int lowChar, int highChar)
static bool IsCharData(char ch)
static bool IsHighSurrogate(int ch)
static Exception CreateInvalidCharException(char[] data, int length, int invCharPos, ExceptionType exceptionType)
static Exception CreateInvalidSurrogatePairException(char low, char hi)
static Exception CreateInvalidHighSurrogateCharException(char hi)
static string[] BuildCharExceptionArgs(string data, int invCharIndex)
override async Task WriteCharEntityAsync(char ch)
override void WriteStartNamespaceDeclaration(string prefix)
override void WriteProcessingInstruction(string name, string text)
unsafe byte * WriteNewLine(byte *pDst)
unsafe int WriteRawWithCharCheckingNoFlush(string text, int index, int count, out bool needWriteNewLine)
unsafe override void WriteString(string text)
async Task WriteElementTextBlockAsync(char[] chars, int index, int count)
override async Task WriteRawAsync(string data)
override async Task WriteRawAsync(char[] buffer, int index, int count)
unsafe void EncodeChar(ref char *pSrc, char *pSrcEnd, ref byte *pDst)
override Task WriteStringAsync(string text)
override void WriteCData(string text)
async Task WriteCommentOrPiAsync(string text, int stopChar)
static unsafe byte * AmpEntity(byte *pDst)
static unsafe void CharToUTF8(ref char *pSrc, char *pSrcEnd, ref byte *pDst)
override Task WriteWhitespaceAsync(string ws)
static unsafe byte * RawStartCData(byte *pDst)
static unsafe byte * CarriageReturnEntity(byte *pDst)
override void WriteEntityRef(string name)
unsafe int WriteCommentOrPiNoFlush(string text, int index, int count, int stopChar, out bool needWriteNewLine)
async Task WriteRawWithCharCheckingAsync(string text)
override void WriteEndElement(string prefix, string localName, string ns)
void ValidateContentChars(string chars, string propertyName, bool allowOnlyWhitespace)
unsafe override void WriteChars(char[] buffer, int index, int count)
unsafe void WriteElementTextBlock(char *pSrc, char *pSrcEnd)
override async Task WriteEntityRefAsync(string name)
unsafe int WriteRawWithCharCheckingNoFlush(char *pSrcBegin, char *pSrcEnd, out bool needWriteNewLine)
override Task WriteEndElementAsync(string prefix, string localName, string ns)
override void WriteFullEndElement(string prefix, string localName, string ns)
override Task WriteCharsAsync(char[] buffer, int index, int count)
unsafe int RawTextNoFlush(string text, int index, int count)
override void WriteXmlDeclaration(string xmldecl)
override async Task WriteCDataAsync(string text)
unsafe byte * InvalidXmlChar(int ch, byte *pDst, bool entitize)
XmlUtf8RawTextWriter(XmlWriterSettings settings)
override void WriteDocType(string name, string pubid, string sysid, string subset)
override void WriteNamespaceDeclaration(string prefix, string namespaceName)
static unsafe byte * CharEntity(byte *pDst, char ch)
unsafe int WriteAttributeTextBlockNoFlush(char *pSrc, char *pSrcEnd)
unsafe override void WriteRaw(char[] buffer, int index, int count)
override void WriteStartAttribute(string prefix, string localName, string ns)
override async Task WriteDocTypeAsync(string name, string pubid, string sysid, string subset)
override Task WriteXmlDeclarationAsync(string xmldecl)
unsafe int WriteElementTextBlockNoFlush(char[] chars, int index, int count, out bool needWriteNewLine)
static unsafe byte * LtEntity(byte *pDst)
async Task _RawTextAsync(string text1, int curIndex1, int leftCount1, string text2=null, string text3=null, string text4=null)
override Task WriteStartAttributeAsync(string prefix, string localName, string ns)
override async Task WriteXmlDeclarationAsync(XmlStandalone standalone)
unsafe void RawText(char *pSrcBegin, char *pSrcEnd)
unsafe override void WriteRaw(string data)
unsafe override void WriteWhitespace(string ws)
override void WriteXmlDeclaration(XmlStandalone standalone)
override async Task WriteSurrogateCharEntityAsync(char lowChar, char highChar)
Task RawTextAsync(string text1, string text2=null, string text3=null, string text4=null)
async Task WriteAttributeTextBlockAsync(char[] chars, int index, int count)
unsafe int WriteCDataSectionNoFlush(string text, int index, int count, out bool needWriteNewLine)
XmlUtf8RawTextWriter(Stream stream, XmlWriterSettings settings)
static unsafe byte * GtEntity(byte *pDst)
async Task WriteRawWithCharCheckingAsync(char[] chars, int index, int count)
static unsafe byte * QuoteEntity(byte *pDst)
unsafe int WriteElementTextBlockNoFlush(char *pSrc, char *pSrcEnd, out bool needWriteNewLine)
unsafe int WriteAttributeTextBlockNoFlush(string text, int index, int count)
unsafe int WriteElementTextBlockNoFlush(string text, int index, int count, out bool needWriteNewLine)
override void WriteStartElement(string prefix, string localName, string ns)
override async Task WriteProcessingInstructionAsync(string name, string text)
override Task WriteFullEndElementAsync(string prefix, string localName, string ns)
async Task _WriteAttributeTextBlockAsync(string text, int curIndex, int leftCount)
static unsafe byte * TabEntity(byte *pDst)
override async Task WriteCommentAsync(string text)
override async Task WriteStartNamespaceDeclarationAsync(string prefix)
override XmlWriterSettings Settings
async Task _WriteElementTextBlockAsync(bool newLine, string text, int curIndex, int leftCount)
override async Task WriteNamespaceDeclarationAsync(string prefix, string namespaceName)
static unsafe byte * RawEndCData(byte *pDst)
unsafe void WriteCommentOrPi(string text, int stopChar)
unsafe void WriteAttributeTextBlock(char *pSrc, char *pSrcEnd)
unsafe void WriteCDataSection(string text)
static unsafe byte * LineFeedEntity(byte *pDst)
unsafe int WriteAttributeTextBlockNoFlush(char[] chars, int index, int count)
async Task WriteCDataSectionAsync(string text)
override Task WriteStartElementAsync(string prefix, string localName, string ns)
unsafe int WriteRawWithCharCheckingNoFlush(char[] chars, int index, int count, out bool needWriteNewLine)
unsafe void WriteRawWithCharChecking(char *pSrcBegin, char *pSrcEnd)
override async ValueTask DisposeAsyncCore()
static unsafe byte * EncodeMultibyteUTF8(int ch, byte *pDst)
override void WriteSurrogateCharEntity(char lowChar, char highChar)
override void WriteComment(string text)
unsafe int RawTextNoFlush(char *pSrcBegin, char *pSrcEnd)
static unsafe byte * EncodeSurrogate(char *pSrc, char *pSrcEnd, byte *pDst)
void CopyTo(Span< T > destination)
ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)
Definition ValueTask.cs:312