Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlBaseWriter.cs
Go to the documentation of this file.
3using System.IO;
6using System.Text;
8
9namespace System.Xml;
10
11internal abstract class XmlBaseWriter : XmlDictionaryWriter
12{
13 private sealed class Element
14 {
15 private string _prefix;
16
17 private string _localName;
18
19 private int _prefixId;
20
21 public string Prefix
22 {
23 get
24 {
25 return _prefix;
26 }
27 set
28 {
29 _prefix = value;
30 }
31 }
32
33 public string LocalName
34 {
35 get
36 {
37 return _localName;
38 }
39 set
40 {
42 }
43 }
44
45 public int PrefixId
46 {
47 get
48 {
49 return _prefixId;
50 }
51 set
52 {
54 }
55 }
56
57 public void Clear()
58 {
59 _prefix = null;
60 _localName = null;
61 _prefixId = 0;
62 }
63 }
64
65 private enum DocumentState : byte
66 {
67 None,
69 Epilog,
70 End
71 }
72
73 private sealed class NamespaceManager
74 {
75 private sealed class XmlAttribute
76 {
78
79 private string _lang;
80
81 private int _depth;
82
83 public int Depth
84 {
85 get
86 {
87 return _depth;
88 }
89 set
90 {
91 _depth = value;
92 }
93 }
94
95 public string XmlLang
96 {
97 get
98 {
99 return _lang;
100 }
101 set
102 {
103 _lang = value;
104 }
105 }
106
108 {
109 get
110 {
111 return _space;
112 }
113 set
114 {
115 _space = value;
116 }
117 }
118
119 public void Clear()
120 {
121 _lang = null;
122 }
123 }
124
125 private sealed class Namespace
126 {
127 private string _prefix;
128
129 private string _ns;
130
132
133 private int _depth;
134
135 private char _prefixChar;
136
137 public int Depth
138 {
139 get
140 {
141 return _depth;
142 }
143 set
144 {
145 _depth = value;
146 }
147 }
148
149 public char PrefixChar => _prefixChar;
150
151 public string Prefix
152 {
153 get
154 {
155 return _prefix;
156 }
158 set
159 {
160 if (value.Length == 1)
161 {
162 _prefixChar = value[0];
163 }
164 else
165 {
166 _prefixChar = '\0';
167 }
168 _prefix = value;
169 }
170 }
171
172 public string Uri
173 {
174 get
175 {
176 return _ns;
177 }
178 set
179 {
180 _ns = value;
181 }
182 }
183
185 {
186 get
187 {
188 return _xNs;
189 }
190 set
191 {
192 _xNs = value;
193 }
194 }
195
196 public void Clear()
197 {
198 _prefix = null;
199 _prefixChar = '\0';
200 _ns = null;
201 _xNs = null;
202 _depth = 0;
203 }
204 }
205
207
209
210 private int _nsCount;
211
212 private int _depth;
213
215
216 private int _attributeCount;
217
219
220 private string _lang;
221
222 private int _nsTop;
223
224 private readonly Namespace _defaultNamespace;
225
226 public string XmlLang => _lang;
227
229
231 {
234 _defaultNamespace.Prefix = string.Empty;
235 _defaultNamespace.Uri = string.Empty;
237 }
238
239 public void Clear()
240 {
241 if (_namespaces == null)
242 {
243 _namespaces = new Namespace[4];
245 }
246 _nsCount = 1;
247 _nsTop = 0;
248 _depth = 0;
249 _attributeCount = 0;
250 _space = XmlSpace.None;
251 _lang = null;
252 _lastNameSpace = null;
253 }
254
255 public void Close()
256 {
257 if (_depth == 0)
258 {
259 if (_namespaces != null && _namespaces.Length > 32)
260 {
261 _namespaces = null;
262 }
263 if (_attributes != null && _attributes.Length > 4)
264 {
265 _attributes = null;
266 }
267 }
268 else
269 {
270 _namespaces = null;
271 _attributes = null;
272 }
273 _lang = null;
274 }
275
277 {
278 int i;
279 for (i = _nsCount; i > 0; i--)
280 {
281 Namespace @namespace = _namespaces[i - 1];
282 if (@namespace.Depth != _depth)
283 {
284 break;
285 }
286 }
287 for (; i < _nsCount; i++)
288 {
290 if (namespace2.UriDictionaryString != null)
291 {
292 writer.WriteXmlnsAttribute(namespace2.Prefix, namespace2.UriDictionaryString);
293 }
294 else
295 {
296 writer.WriteXmlnsAttribute(namespace2.Prefix, namespace2.Uri);
297 }
298 }
299 }
300
301 public void EnterScope()
302 {
303 _depth++;
304 }
305
306 public void ExitScope()
307 {
308 while (_nsCount > 0)
309 {
310 Namespace @namespace = _namespaces[_nsCount - 1];
311 if (@namespace.Depth != _depth)
312 {
313 break;
314 }
315 if (_lastNameSpace == @namespace)
316 {
317 _lastNameSpace = null;
318 }
319 @namespace.Clear();
320 _nsCount--;
321 }
322 while (_attributeCount > 0)
323 {
325 if (xmlAttribute.Depth != _depth)
326 {
327 break;
328 }
330 _lang = xmlAttribute.XmlLang;
331 xmlAttribute.Clear();
333 }
334 _depth--;
335 }
336
337 public void AddLangAttribute(string lang)
338 {
339 AddAttribute();
340 _lang = lang;
341 }
342
344 {
345 AddAttribute();
346 _space = space;
347 }
348
372
374 {
375 if (uri.Length == 0)
376 {
378 return string.Empty;
379 }
380 for (int i = 0; i < s_prefixes.Length; i++)
381 {
382 string text = s_prefixes[i];
383 bool flag = false;
384 for (int num = _nsCount - 1; num >= _nsTop; num--)
385 {
386 Namespace @namespace = _namespaces[num];
387 if (@namespace.Prefix == text)
388 {
389 flag = true;
390 break;
391 }
392 }
393 if (!flag)
394 {
396 return text;
397 }
398 }
399 return null;
400 }
401
403 {
404 if (LookupNamespace(prefix) != uri)
405 {
407 }
408 }
409
411 {
412 if (prefix.Length >= 3 && (prefix[0] & -33) == 88 && (prefix[1] & -33) == 77 && (prefix[2] & -33) == 76)
413 {
414 if ((!(prefix == "xml") || !(uri == "http://www.w3.org/XML/1998/namespace")) && (!(prefix == "xmlns") || !(uri == "http://www.w3.org/2000/xmlns/")))
415 {
417 }
418 return;
419 }
420 Namespace @namespace;
421 for (int num = _nsCount - 1; num >= 0; num--)
422 {
423 @namespace = _namespaces[num];
424 if (@namespace.Depth != _depth)
425 {
426 break;
427 }
428 if (@namespace.Prefix == prefix)
429 {
430 if (@namespace.Uri == uri)
431 {
432 return;
433 }
435 }
436 }
437 if (prefix.Length != 0 && uri.Length == 0)
438 {
440 }
441 if (uri.Length == "http://www.w3.org/2000/xmlns/".Length && uri == "http://www.w3.org/2000/xmlns/")
442 {
444 }
445 if (uri.Length == "http://www.w3.org/XML/1998/namespace".Length && uri[18] == 'X' && uri == "http://www.w3.org/XML/1998/namespace")
446 {
448 }
449 if (_namespaces.Length == _nsCount)
450 {
451 Namespace[] array = new Namespace[_nsCount * 2];
454 }
455 @namespace = _namespaces[_nsCount];
456 if (@namespace == null)
457 {
458 @namespace = new Namespace();
459 _namespaces[_nsCount] = @namespace;
460 }
463 @namespace.Uri = uri;
465 _nsCount++;
466 _lastNameSpace = null;
467 }
468
469 public string LookupPrefix(string ns)
470 {
471 if (_lastNameSpace != null && _lastNameSpace.Uri == ns)
472 {
473 return _lastNameSpace.Prefix;
474 }
475 int nsCount = _nsCount;
476 for (int num = nsCount - 1; num >= _nsTop; num--)
477 {
478 Namespace @namespace = _namespaces[num];
479 if ((object)@namespace.Uri == ns)
480 {
481 string prefix = @namespace.Prefix;
482 bool flag = false;
483 for (int i = num + 1; i < nsCount; i++)
484 {
485 if (_namespaces[i].Prefix == prefix)
486 {
487 flag = true;
488 break;
489 }
490 }
491 if (!flag)
492 {
493 _lastNameSpace = @namespace;
494 return prefix;
495 }
496 }
497 }
498 for (int num2 = nsCount - 1; num2 >= _nsTop; num2--)
499 {
501 if (namespace2.Uri == ns)
502 {
503 string prefix2 = namespace2.Prefix;
504 bool flag2 = false;
505 for (int j = num2 + 1; j < nsCount; j++)
506 {
507 if (_namespaces[j].Prefix == prefix2)
508 {
509 flag2 = true;
510 break;
511 }
512 }
513 if (!flag2)
514 {
516 return prefix2;
517 }
518 }
519 }
520 if (ns.Length == 0)
521 {
522 bool flag3 = true;
523 for (int num3 = nsCount - 1; num3 >= _nsTop; num3--)
524 {
525 if (_namespaces[num3].Prefix.Length == 0)
526 {
527 flag3 = false;
528 break;
529 }
530 }
531 if (flag3)
532 {
533 return string.Empty;
534 }
535 }
536 if (ns == "http://www.w3.org/2000/xmlns/")
537 {
538 return "xmlns";
539 }
540 if (ns == "http://www.w3.org/XML/1998/namespace")
541 {
542 return "xml";
543 }
544 return null;
545 }
546
547 public string LookupAttributePrefix(string ns)
548 {
549 if (_lastNameSpace != null && _lastNameSpace.Uri == ns && _lastNameSpace.Prefix.Length != 0)
550 {
551 return _lastNameSpace.Prefix;
552 }
553 int nsCount = _nsCount;
554 for (int num = nsCount - 1; num >= _nsTop; num--)
555 {
556 Namespace @namespace = _namespaces[num];
557 if ((object)@namespace.Uri == ns)
558 {
559 string prefix = @namespace.Prefix;
560 if (prefix.Length != 0)
561 {
562 bool flag = false;
563 for (int i = num + 1; i < nsCount; i++)
564 {
565 if (_namespaces[i].Prefix == prefix)
566 {
567 flag = true;
568 break;
569 }
570 }
571 if (!flag)
572 {
573 _lastNameSpace = @namespace;
574 return prefix;
575 }
576 }
577 }
578 }
579 for (int num2 = nsCount - 1; num2 >= _nsTop; num2--)
580 {
582 if (namespace2.Uri == ns)
583 {
584 string prefix2 = namespace2.Prefix;
585 if (prefix2.Length != 0)
586 {
587 bool flag2 = false;
588 for (int j = num2 + 1; j < nsCount; j++)
589 {
590 if (_namespaces[j].Prefix == prefix2)
591 {
592 flag2 = true;
593 break;
594 }
595 }
596 if (!flag2)
597 {
599 return prefix2;
600 }
601 }
602 }
603 }
604 if (ns.Length == 0)
605 {
606 return string.Empty;
607 }
608 return null;
609 }
610
611 public string LookupNamespace(string prefix)
612 {
613 int nsCount = _nsCount;
614 if (prefix.Length == 0)
615 {
616 for (int num = nsCount - 1; num >= _nsTop; num--)
617 {
618 Namespace @namespace = _namespaces[num];
619 if (@namespace.Prefix.Length == 0)
620 {
621 return @namespace.Uri;
622 }
623 }
624 return string.Empty;
625 }
626 if (prefix.Length == 1)
627 {
628 char c = prefix[0];
629 for (int num2 = nsCount - 1; num2 >= _nsTop; num2--)
630 {
632 if (namespace2.PrefixChar == c)
633 {
634 return namespace2.Uri;
635 }
636 }
637 return null;
638 }
639 for (int num3 = nsCount - 1; num3 >= _nsTop; num3--)
640 {
642 if (namespace3.Prefix == prefix)
643 {
644 return namespace3.Uri;
645 }
646 }
647 if (prefix == "xmlns")
648 {
649 return "http://www.w3.org/2000/xmlns/";
650 }
651 if (prefix == "xml")
652 {
653 return "http://www.w3.org/XML/1998/namespace";
654 }
655 return null;
656 }
657
659 {
660 int nsCount = _nsCount;
661 for (int i = 1; i < nsCount; i++)
662 {
663 Namespace @namespace = _namespaces[i];
664 bool flag = false;
665 for (int j = i + 1; j < nsCount; j++)
666 {
667 if (flag)
668 {
669 break;
670 }
671 flag = @namespace.Prefix == _namespaces[j].Prefix;
672 }
673 if (!flag)
674 {
675 signingWriter.WriteXmlnsAttribute(@namespace.Prefix, @namespace.Uri);
676 }
677 }
678 }
679 }
680
682
683 private readonly NamespaceManager _nsMgr;
684
686
687 private int _depth;
688
689 private string _attributeLocalName;
690
691 private string _attributeValue;
692
693 private bool _isXmlAttribute;
694
695 private bool _isXmlnsAttribute;
696
698
700
701 private byte[] _trailBytes;
702
703 private int _trailByteCount;
704
706
708
709 private bool _inList;
710
711 private const string xmlnsNamespace = "http://www.w3.org/2000/xmlns/";
712
713 private const string xmlNamespace = "http://www.w3.org/XML/1998/namespace";
714
716
717 private static readonly string[] s_prefixes = new string[26]
718 {
719 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
720 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
721 "u", "v", "w", "x", "y", "z"
722 };
723
724 protected bool IsClosed => _writeState == WriteState.Closed;
725
727 {
728 get
729 {
730 if (_binhexEncoding == null)
731 {
733 }
734 return _binhexEncoding;
735 }
736 }
737
738 public override string XmlLang => _nsMgr.XmlLang;
739
740 public override XmlSpace XmlSpace => _nsMgr.XmlSpace;
741
743
744 public override bool CanCanonicalize => true;
745
746 protected bool Signing => _writer == _signingWriter;
747
748 protected XmlBaseWriter()
749 {
750 _nsMgr = new NamespaceManager();
751 _writeState = WriteState.Start;
753 }
754
756 {
757 _inList = false;
758 _writer = writer;
760 _writeState = WriteState.Start;
762 _nsMgr.Clear();
763 if (_depth != 0)
764 {
765 _elements = null;
766 _depth = 0;
767 }
768 _attributeLocalName = null;
769 _attributeValue = null;
770 }
771
772 public override void Flush()
773 {
774 if (IsClosed)
775 {
776 ThrowClosed();
777 }
778 _writer.Flush();
779 }
780
781 public override Task FlushAsync()
782 {
783 if (IsClosed)
784 {
785 ThrowClosed();
786 }
787 return _writer.FlushAsync();
788 }
789
790 public override void Close()
791 {
792 if (IsClosed)
793 {
794 return;
795 }
796 try
797 {
799 AutoComplete(WriteState.Closed);
800 _writer.Flush();
801 }
802 finally
803 {
804 _nsMgr.Close();
805 if (_depth != 0)
806 {
807 _elements = null;
808 _depth = 0;
809 }
810 _attributeValue = null;
811 _attributeLocalName = null;
813 if (_signingWriter != null)
814 {
816 }
817 }
818 }
819
825
826 public override void WriteXmlnsAttribute(string prefix, string ns)
827 {
828 if (IsClosed)
829 {
830 ThrowClosed();
831 }
832 if (ns == null)
833 {
835 }
836 if (_writeState != WriteState.Element)
837 {
839 }
840 if (prefix == null)
841 {
843 if (prefix == null)
844 {
845 GeneratePrefix(ns, null);
846 }
847 }
848 else
849 {
851 }
852 }
853
854 public override void WriteXmlnsAttribute(string prefix, XmlDictionaryString ns)
855 {
856 if (IsClosed)
857 {
858 ThrowClosed();
859 }
860 if (ns == null)
861 {
863 }
864 if (_writeState != WriteState.Element)
865 {
867 }
868 if (prefix == null)
869 {
871 if (prefix == null)
872 {
873 GeneratePrefix(ns.Value, ns);
874 }
875 }
876 else
877 {
879 }
880 }
881
882 private void StartAttribute([AllowNull] ref string prefix, string localName, string ns, XmlDictionaryString xNs)
883 {
884 if (IsClosed)
885 {
886 ThrowClosed();
887 }
888 if (_writeState == WriteState.Attribute)
889 {
891 }
892 if (localName == null || (localName.Length == 0 && prefix != "xmlns"))
893 {
895 }
896 if (_writeState != WriteState.Element)
897 {
899 }
900 if (prefix == null)
901 {
902 if (ns == "http://www.w3.org/2000/xmlns/" && localName != "xmlns")
903 {
904 prefix = "xmlns";
905 }
906 else if (ns == "http://www.w3.org/XML/1998/namespace")
907 {
908 prefix = "xml";
909 }
910 else
911 {
912 prefix = string.Empty;
913 }
914 }
915 if (prefix.Length == 0 && localName == "xmlns")
916 {
917 prefix = "xmlns";
918 localName = string.Empty;
919 }
920 _isXmlnsAttribute = false;
921 _isXmlAttribute = false;
922 if (prefix == "xml")
923 {
924 if (ns != null && ns != "http://www.w3.org/XML/1998/namespace")
925 {
926 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.SR.Format(System.SR.XmlPrefixBoundToNamespace, "xml", "http://www.w3.org/XML/1998/namespace", ns), "ns"));
927 }
928 _isXmlAttribute = true;
929 _attributeValue = string.Empty;
930 _attributeLocalName = localName;
931 }
932 else if (prefix == "xmlns")
933 {
934 if (ns != null && ns != "http://www.w3.org/2000/xmlns/")
935 {
936 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.SR.Format(System.SR.XmlPrefixBoundToNamespace, "xmlns", "http://www.w3.org/2000/xmlns/", ns), "ns"));
937 }
938 _isXmlnsAttribute = true;
939 _attributeValue = string.Empty;
940 _attributeLocalName = localName;
941 }
942 else if (ns == null)
943 {
944 if (prefix.Length == 0)
945 {
946 ns = string.Empty;
947 }
948 else
949 {
951 if (ns == null)
952 {
954 }
955 }
956 }
957 else if (ns.Length == 0)
958 {
959 if (prefix.Length != 0)
960 {
962 }
963 }
964 else if (prefix.Length == 0)
965 {
966 string text = _nsMgr.LookupAttributePrefix(ns);
967 if (text == null)
968 {
969 if (ns.Length == "http://www.w3.org/2000/xmlns/".Length && ns == "http://www.w3.org/2000/xmlns/")
970 {
972 }
973 if (ns.Length == "http://www.w3.org/XML/1998/namespace".Length && ns == "http://www.w3.org/XML/1998/namespace")
974 {
976 }
977 text = GeneratePrefix(ns, xNs);
978 }
979 prefix = text;
980 }
981 else
982 {
984 }
985 _writeState = WriteState.Attribute;
986 }
987
988 public override void WriteStartAttribute(string prefix, string localName, string namespaceUri)
989 {
990 StartAttribute(ref prefix, localName, namespaceUri, null);
992 {
994 }
995 }
996
997 public override void WriteStartAttribute(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri)
998 {
999 StartAttribute(ref prefix, localName?.Value, namespaceUri?.Value, namespaceUri);
1000 if (!_isXmlnsAttribute)
1001 {
1003 }
1004 }
1005
1006 public override void WriteEndAttribute()
1007 {
1008 if (IsClosed)
1009 {
1010 ThrowClosed();
1011 }
1012 if (_writeState != WriteState.Attribute)
1013 {
1015 }
1016 FlushBase64();
1017 try
1018 {
1019 if (_isXmlAttribute)
1020 {
1021 if (_attributeLocalName == "lang")
1022 {
1024 }
1025 else if (_attributeLocalName == "space")
1026 {
1027 if (_attributeValue == "preserve")
1028 {
1030 }
1031 else
1032 {
1033 if (!(_attributeValue == "default"))
1034 {
1036 }
1038 }
1039 }
1040 _isXmlAttribute = false;
1041 _attributeLocalName = null;
1042 _attributeValue = null;
1043 }
1045 {
1047 _isXmlnsAttribute = false;
1048 _attributeLocalName = null;
1049 _attributeValue = null;
1050 }
1051 else
1052 {
1054 }
1055 }
1056 finally
1057 {
1058 _writeState = WriteState.Element;
1059 }
1060 }
1061
1062 protected override Task WriteEndAttributeAsync()
1063 {
1064 if (IsClosed)
1065 {
1066 ThrowClosed();
1067 }
1068 if (_writeState != WriteState.Attribute)
1069 {
1071 }
1073 }
1074
1076 {
1078 try
1079 {
1080 if (_isXmlAttribute)
1081 {
1082 if (_attributeLocalName == "lang")
1083 {
1085 }
1086 else if (_attributeLocalName == "space")
1087 {
1088 if (_attributeValue == "preserve")
1089 {
1091 }
1092 else
1093 {
1094 if (!(_attributeValue == "default"))
1095 {
1097 }
1099 }
1100 }
1101 _isXmlAttribute = false;
1102 _attributeLocalName = null;
1103 _attributeValue = null;
1104 }
1106 {
1108 _isXmlnsAttribute = false;
1109 _attributeLocalName = null;
1110 _attributeValue = null;
1111 }
1112 else
1113 {
1115 }
1116 }
1117 finally
1118 {
1119 _writeState = WriteState.Element;
1120 }
1121 }
1122
1123 public override void WriteComment(string text)
1124 {
1125 if (IsClosed)
1126 {
1127 ThrowClosed();
1128 }
1129 if (_writeState == WriteState.Attribute)
1130 {
1132 }
1133 if (text == null)
1134 {
1135 text = string.Empty;
1136 }
1137 else if (text.IndexOf("--", StringComparison.Ordinal) != -1 || (text.Length > 0 && text[text.Length - 1] == '-'))
1138 {
1140 }
1141 StartComment();
1142 FlushBase64();
1144 EndComment();
1145 }
1146
1147 public override void WriteFullEndElement()
1148 {
1149 if (IsClosed)
1150 {
1151 ThrowClosed();
1152 }
1153 if (_writeState == WriteState.Attribute)
1154 {
1156 }
1157 if (_writeState != WriteState.Element && _writeState != WriteState.Content)
1158 {
1160 }
1161 AutoComplete(WriteState.Content);
1163 }
1164
1165 public override void WriteCData(string text)
1166 {
1167 if (IsClosed)
1168 {
1169 ThrowClosed();
1170 }
1171 if (_writeState == WriteState.Attribute)
1172 {
1174 }
1175 if (text == null)
1176 {
1177 text = string.Empty;
1178 }
1179 if (text.Length > 0)
1180 {
1181 StartContent();
1182 FlushBase64();
1184 EndContent();
1185 }
1186 }
1187
1188 public override void WriteDocType(string name, string pubid, string sysid, string subset)
1189 {
1191 }
1192
1193 private void StartElement(ref string prefix, string localName, string ns, XmlDictionaryString xNs)
1194 {
1195 if (IsClosed)
1196 {
1197 ThrowClosed();
1198 }
1199 if (_documentState == DocumentState.Epilog)
1200 {
1202 }
1203 if (localName == null)
1204 {
1206 }
1207 if (localName.Length == 0)
1208 {
1210 }
1211 if (_writeState == WriteState.Attribute)
1212 {
1214 }
1215 FlushBase64();
1216 AutoComplete(WriteState.Element);
1217 Element element = EnterScope();
1218 if (ns == null)
1219 {
1220 if (prefix == null)
1221 {
1222 prefix = string.Empty;
1223 }
1225 if (ns == null)
1226 {
1228 }
1229 }
1230 else if (prefix == null)
1231 {
1233 if (prefix == null)
1234 {
1235 prefix = string.Empty;
1236 _nsMgr.AddNamespace(string.Empty, ns, xNs);
1237 }
1238 }
1239 else
1240 {
1242 }
1244 element.LocalName = localName;
1245 }
1246
1247 private void PreStartElementAsyncCheck(string prefix, string localName, string ns, XmlDictionaryString xNs)
1248 {
1249 if (IsClosed)
1250 {
1251 ThrowClosed();
1252 }
1253 if (_documentState == DocumentState.Epilog)
1254 {
1256 }
1257 if (localName == null)
1258 {
1260 }
1261 if (localName.Length == 0)
1262 {
1264 }
1265 if (_writeState == WriteState.Attribute)
1266 {
1268 }
1269 }
1270
1271 private async Task StartElementAndWriteStartElementAsync(string prefix, string localName, string namespaceUri)
1272 {
1273 prefix = await StartElementAsync(prefix, localName, namespaceUri, null).ConfigureAwait(continueOnCapturedContext: false);
1275 }
1276
1277 private async Task<string> StartElementAsync(string prefix, string localName, string ns, XmlDictionaryString xNs)
1278 {
1281 Element element = EnterScope();
1282 if (ns == null)
1283 {
1284 if (prefix == null)
1285 {
1286 prefix = string.Empty;
1287 }
1289 if (ns == null)
1290 {
1292 }
1293 }
1294 else if (prefix == null)
1295 {
1297 if (prefix == null)
1298 {
1299 prefix = string.Empty;
1300 _nsMgr.AddNamespace(string.Empty, ns, xNs);
1301 }
1302 }
1303 else
1304 {
1306 }
1308 element.LocalName = localName;
1309 return prefix;
1310 }
1311
1312 public override void WriteStartElement(string prefix, string localName, string namespaceUri)
1313 {
1314 StartElement(ref prefix, localName, namespaceUri, null);
1315 _writer.WriteStartElement(prefix, localName);
1316 }
1317
1318 public override Task WriteStartElementAsync(string prefix, string localName, string namespaceUri)
1319 {
1320 PreStartElementAsyncCheck(prefix, localName, namespaceUri, null);
1321 return StartElementAndWriteStartElementAsync(prefix, localName, namespaceUri);
1322 }
1323
1324 public override void WriteStartElement(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri)
1325 {
1326 StartElement(ref prefix, localName.Value, namespaceUri?.Value, namespaceUri);
1327 _writer.WriteStartElement(prefix, localName);
1328 }
1329
1330 public override void WriteEndElement()
1331 {
1332 if (IsClosed)
1333 {
1334 ThrowClosed();
1335 }
1336 if (_depth == 0)
1337 {
1339 }
1340 if (_writeState == WriteState.Attribute)
1341 {
1343 }
1344 FlushBase64();
1345 if (_writeState == WriteState.Element)
1346 {
1349 }
1350 else
1351 {
1352 Element element = _elements[_depth];
1353 _writer.WriteEndElement(element.Prefix, element.LocalName);
1354 }
1355 ExitScope();
1356 _writeState = WriteState.Content;
1357 }
1358
1359 public override Task WriteEndElementAsync()
1360 {
1361 if (IsClosed)
1362 {
1363 ThrowClosed();
1364 }
1365 if (_depth == 0)
1366 {
1368 }
1369 return WriteEndElementAsyncImpl();
1370 }
1371
1373 {
1374 if (_writeState == WriteState.Attribute)
1375 {
1377 }
1378 FlushBase64();
1379 if (_writeState == WriteState.Element)
1380 {
1383 }
1384 else
1385 {
1386 Element element = _elements[_depth];
1388 }
1389 ExitScope();
1390 _writeState = WriteState.Content;
1391 }
1392
1394 {
1396 _depth++;
1397 if (_elements == null)
1398 {
1399 _elements = new Element[4];
1400 }
1401 else if (_elements.Length == _depth)
1402 {
1403 Element[] array = new Element[_depth * 2];
1405 _elements = array;
1406 }
1407 Element element = _elements[_depth];
1408 if (element == null)
1409 {
1410 element = new Element();
1411 _elements[_depth] = element;
1412 }
1413 return element;
1414 }
1415
1416 private void ExitScope()
1417 {
1419 _depth--;
1420 if (_depth == 0 && _documentState == DocumentState.Document)
1421 {
1423 }
1424 _nsMgr.ExitScope();
1425 }
1426
1427 protected void FlushElement()
1428 {
1429 if (_writeState == WriteState.Element)
1430 {
1431 AutoComplete(WriteState.Content);
1432 }
1433 }
1434
1436 {
1437 if (_writeState != WriteState.Element)
1438 {
1439 return Task.CompletedTask;
1440 }
1441 return AutoCompleteAsync(WriteState.Content);
1442 }
1443
1444 protected void StartComment()
1445 {
1446 FlushElement();
1447 }
1448
1449 protected void EndComment()
1450 {
1451 }
1452
1453 protected void StartContent()
1454 {
1455 FlushElement();
1456 if (_depth == 0)
1457 {
1459 }
1460 }
1461
1470
1471 protected void StartContent(char ch)
1472 {
1473 FlushElement();
1474 if (_depth == 0)
1475 {
1477 }
1478 }
1479
1480 protected void StartContent(string s)
1481 {
1482 FlushElement();
1483 if (_depth == 0)
1484 {
1486 }
1487 }
1488
1489 protected void StartContent(char[] chars, int offset, int count)
1490 {
1491 FlushElement();
1492 if (_depth == 0)
1493 {
1495 }
1496 }
1497
1505
1506 private void VerifyWhitespace(string s)
1507 {
1508 for (int i = 0; i < s.Length; i++)
1509 {
1510 if (!IsWhitespace(s[i]))
1511 {
1513 }
1514 }
1515 }
1516
1517 private void VerifyWhitespace(char[] chars, int offset, int count)
1518 {
1519 for (int i = 0; i < count; i++)
1520 {
1521 if (!IsWhitespace(chars[offset + i]))
1522 {
1524 }
1525 }
1526 }
1527
1528 private bool IsWhitespace(char ch)
1529 {
1530 if (ch != ' ' && ch != '\n' && ch != '\r')
1531 {
1532 return ch == 't';
1533 }
1534 return true;
1535 }
1536
1537 protected void EndContent()
1538 {
1539 }
1540
1542 {
1543 if (_writeState == WriteState.Element)
1544 {
1546 }
1548 }
1549
1558
1559 private void EndStartElement()
1560 {
1563 }
1564
1570
1571 public override string LookupPrefix(string ns)
1572 {
1573 if (ns == null)
1574 {
1576 }
1577 if (IsClosed)
1578 {
1579 ThrowClosed();
1580 }
1581 return _nsMgr.LookupPrefix(ns);
1582 }
1583
1584 private string GetQualifiedNamePrefix(string namespaceUri, XmlDictionaryString xNs)
1585 {
1586 string text = _nsMgr.LookupPrefix(namespaceUri);
1587 if (text == null)
1588 {
1589 if (_writeState != WriteState.Attribute)
1590 {
1592 }
1593 text = GeneratePrefix(namespaceUri, xNs);
1594 }
1595 return text;
1596 }
1597
1598 public override void WriteQualifiedName(string localName, string namespaceUri)
1599 {
1600 if (IsClosed)
1601 {
1602 ThrowClosed();
1603 }
1604 if (localName == null)
1605 {
1607 }
1608 if (localName.Length == 0)
1609 {
1611 }
1612 if (namespaceUri == null)
1613 {
1614 namespaceUri = string.Empty;
1615 }
1616 string qualifiedNamePrefix = GetQualifiedNamePrefix(namespaceUri, null);
1617 if (qualifiedNamePrefix.Length != 0)
1618 {
1620 WriteString(":");
1621 }
1622 WriteString(localName);
1623 }
1624
1625 public override void WriteQualifiedName(XmlDictionaryString localName, XmlDictionaryString namespaceUri)
1626 {
1627 if (IsClosed)
1628 {
1629 ThrowClosed();
1630 }
1631 if (localName == null)
1632 {
1634 }
1635 if (localName.Value.Length == 0)
1636 {
1638 }
1639 if (namespaceUri == null)
1640 {
1641 namespaceUri = XmlDictionaryString.Empty;
1642 }
1643 string qualifiedNamePrefix = GetQualifiedNamePrefix(namespaceUri.Value, namespaceUri);
1644 FlushBase64();
1645 if (_attributeValue != null)
1646 {
1647 WriteAttributeText(qualifiedNamePrefix + ":" + namespaceUri.Value);
1648 }
1649 if (!_isXmlnsAttribute)
1650 {
1651 StartContent();
1653 EndContent();
1654 }
1655 }
1656
1657 public override void WriteStartDocument()
1658 {
1659 if (IsClosed)
1660 {
1661 ThrowClosed();
1662 }
1663 if (_writeState != 0)
1664 {
1666 }
1667 _writeState = WriteState.Prolog;
1668 _documentState = DocumentState.Document;
1670 }
1671
1672 public override void WriteStartDocument(bool standalone)
1673 {
1674 if (IsClosed)
1675 {
1676 ThrowClosed();
1677 }
1679 }
1680
1681 public override void WriteProcessingInstruction(string name, string text)
1682 {
1683 if (IsClosed)
1684 {
1685 ThrowClosed();
1686 }
1687 if (name != "xml")
1688 {
1690 }
1691 if (_writeState != 0)
1692 {
1694 }
1696 }
1697
1698 private void FinishDocument()
1699 {
1700 if (_writeState == WriteState.Attribute)
1701 {
1703 }
1704 while (_depth > 0)
1705 {
1707 }
1708 }
1709
1710 public override void WriteEndDocument()
1711 {
1712 if (IsClosed)
1713 {
1714 ThrowClosed();
1715 }
1716 if (_writeState == WriteState.Start || _writeState == WriteState.Prolog)
1717 {
1719 }
1721 _writeState = WriteState.Start;
1723 }
1724
1725 public override void WriteEntityRef(string name)
1726 {
1728 }
1729
1730 public override void WriteName(string name)
1731 {
1732 if (IsClosed)
1733 {
1734 ThrowClosed();
1735 }
1736 WriteString(name);
1737 }
1738
1739 public override void WriteNmToken(string name)
1740 {
1742 }
1743
1744 public override void WriteWhitespace(string whitespace)
1745 {
1746 if (IsClosed)
1747 {
1748 ThrowClosed();
1749 }
1750 if (whitespace == null)
1751 {
1753 }
1754 foreach (char c in whitespace)
1755 {
1756 if (c != ' ' && c != '\t' && c != '\n' && c != '\r')
1757 {
1759 }
1760 }
1762 }
1763
1764 public override void WriteString(string value)
1765 {
1766 if (IsClosed)
1767 {
1768 ThrowClosed();
1769 }
1770 if (value == null)
1771 {
1772 value = string.Empty;
1773 }
1774 if (value.Length > 0 || _inList)
1775 {
1776 FlushBase64();
1777 if (_attributeValue != null)
1778 {
1780 }
1781 if (!_isXmlnsAttribute)
1782 {
1785 EndContent();
1786 }
1787 }
1788 }
1789
1791 {
1792 if (IsClosed)
1793 {
1794 ThrowClosed();
1795 }
1796 if (value == null)
1797 {
1799 }
1800 if (value.Value.Length > 0)
1801 {
1802 FlushBase64();
1803 if (_attributeValue != null)
1804 {
1806 }
1807 if (!_isXmlnsAttribute)
1808 {
1809 StartContent(value.Value);
1811 EndContent();
1812 }
1813 }
1814 }
1815
1816 public override void WriteChars(char[] chars, int offset, int count)
1817 {
1818 if (IsClosed)
1819 {
1820 ThrowClosed();
1821 }
1822 if (chars == null)
1823 {
1825 }
1826 if (offset < 0)
1827 {
1829 }
1830 if (count < 0)
1831 {
1833 }
1834 if (count > chars.Length - offset)
1835 {
1837 }
1838 if (count > 0)
1839 {
1840 FlushBase64();
1841 if (_attributeValue != null)
1842 {
1843 WriteAttributeText(new string(chars, offset, count));
1844 }
1845 if (!_isXmlnsAttribute)
1846 {
1849 EndContent();
1850 }
1851 }
1852 }
1853
1854 public override void WriteRaw(string value)
1855 {
1856 if (IsClosed)
1857 {
1858 ThrowClosed();
1859 }
1860 if (value == null)
1861 {
1862 value = string.Empty;
1863 }
1864 if (value.Length > 0)
1865 {
1866 FlushBase64();
1867 if (_attributeValue != null)
1868 {
1870 }
1871 if (!_isXmlnsAttribute)
1872 {
1875 EndContent();
1876 }
1877 }
1878 }
1879
1880 public override void WriteRaw(char[] chars, int offset, int count)
1881 {
1882 if (IsClosed)
1883 {
1884 ThrowClosed();
1885 }
1886 if (chars == null)
1887 {
1889 }
1890 if (offset < 0)
1891 {
1893 }
1894 if (count < 0)
1895 {
1897 }
1898 if (count > chars.Length - offset)
1899 {
1901 }
1902 if (count > 0)
1903 {
1904 FlushBase64();
1905 if (_attributeValue != null)
1906 {
1907 WriteAttributeText(new string(chars, offset, count));
1908 }
1909 if (!_isXmlnsAttribute)
1910 {
1913 EndContent();
1914 }
1915 }
1916 }
1917
1918 public override void WriteCharEntity(char ch)
1919 {
1920 if (IsClosed)
1921 {
1922 ThrowClosed();
1923 }
1924 if (ch >= '\ud800' && ch <= '\udfff')
1925 {
1927 }
1928 if (_attributeValue != null)
1929 {
1930 WriteAttributeText(ch.ToString());
1931 }
1932 if (!_isXmlnsAttribute)
1933 {
1935 FlushBase64();
1937 EndContent();
1938 }
1939 }
1940
1941 public override void WriteSurrogateCharEntity(char lowChar, char highChar)
1942 {
1943 if (IsClosed)
1944 {
1945 ThrowClosed();
1946 }
1948 if (_attributeValue != null)
1949 {
1950 Span<char> span = stackalloc char[2] { highChar, lowChar };
1951 WriteAttributeText(new string(span));
1952 }
1953 if (!_isXmlnsAttribute)
1954 {
1955 StartContent();
1956 FlushBase64();
1958 EndContent();
1959 }
1960 }
1961
1962 public override void WriteValue(object value)
1963 {
1964 if (IsClosed)
1965 {
1966 ThrowClosed();
1967 }
1968 if (value == null)
1969 {
1971 }
1972 if (value is object[])
1973 {
1974 WriteValue((object[])value);
1975 }
1976 else if (value is Array)
1977 {
1979 }
1980 else
1981 {
1983 }
1984 }
1985
1986 protected void WritePrimitiveValue(object value)
1987 {
1988 if (IsClosed)
1989 {
1990 ThrowClosed();
1991 }
1992 if (value == null)
1993 {
1995 }
1996 if (value is ulong)
1997 {
1998 WriteValue((ulong)value);
1999 return;
2000 }
2001 if (value is string)
2002 {
2003 WriteValue((string)value);
2004 return;
2005 }
2006 if (value is int)
2007 {
2008 WriteValue((int)value);
2009 return;
2010 }
2011 if (value is long)
2012 {
2013 WriteValue((long)value);
2014 return;
2015 }
2016 if (value is bool)
2017 {
2018 WriteValue((bool)value);
2019 return;
2020 }
2021 if (value is double)
2022 {
2023 WriteValue((double)value);
2024 return;
2025 }
2026 if (value is DateTime)
2027 {
2029 return;
2030 }
2031 if (value is float)
2032 {
2033 WriteValue((float)value);
2034 return;
2035 }
2036 if (value is decimal)
2037 {
2038 WriteValue((decimal)value);
2039 return;
2040 }
2042 {
2044 return;
2045 }
2046 if (value is UniqueId)
2047 {
2049 return;
2050 }
2051 if (value is Guid)
2052 {
2054 return;
2055 }
2056 if (value is TimeSpan)
2057 {
2059 return;
2060 }
2061 if (value.GetType().IsArray)
2062 {
2064 }
2065 base.WriteValue(value);
2066 }
2067
2068 public override void WriteValue(string value)
2069 {
2070 if (IsClosed)
2071 {
2072 ThrowClosed();
2073 }
2075 }
2076
2077 public override void WriteValue(int value)
2078 {
2079 if (IsClosed)
2080 {
2081 ThrowClosed();
2082 }
2083 FlushBase64();
2084 if (_attributeValue != null)
2085 {
2087 }
2088 if (!_isXmlnsAttribute)
2089 {
2090 StartContent();
2092 EndContent();
2093 }
2094 }
2095
2096 public override void WriteValue(long value)
2097 {
2098 if (IsClosed)
2099 {
2100 ThrowClosed();
2101 }
2102 FlushBase64();
2103 if (_attributeValue != null)
2104 {
2106 }
2107 if (!_isXmlnsAttribute)
2108 {
2109 StartContent();
2111 EndContent();
2112 }
2113 }
2114
2115 private void WriteValue(ulong value)
2116 {
2117 if (IsClosed)
2118 {
2119 ThrowClosed();
2120 }
2121 FlushBase64();
2122 if (_attributeValue != null)
2123 {
2125 }
2126 if (!_isXmlnsAttribute)
2127 {
2128 StartContent();
2130 EndContent();
2131 }
2132 }
2133
2134 public override void WriteValue(bool value)
2135 {
2136 if (IsClosed)
2137 {
2138 ThrowClosed();
2139 }
2140 FlushBase64();
2141 if (_attributeValue != null)
2142 {
2144 }
2145 if (!_isXmlnsAttribute)
2146 {
2147 StartContent();
2149 EndContent();
2150 }
2151 }
2152
2153 public override void WriteValue(decimal value)
2154 {
2155 if (IsClosed)
2156 {
2157 ThrowClosed();
2158 }
2159 FlushBase64();
2160 if (_attributeValue != null)
2161 {
2163 }
2164 if (!_isXmlnsAttribute)
2165 {
2166 StartContent();
2168 EndContent();
2169 }
2170 }
2171
2172 public override void WriteValue(float value)
2173 {
2174 if (IsClosed)
2175 {
2176 ThrowClosed();
2177 }
2178 FlushBase64();
2179 if (_attributeValue != null)
2180 {
2182 }
2183 if (!_isXmlnsAttribute)
2184 {
2185 StartContent();
2187 EndContent();
2188 }
2189 }
2190
2191 public override void WriteValue(double value)
2192 {
2193 if (IsClosed)
2194 {
2195 ThrowClosed();
2196 }
2197 FlushBase64();
2198 if (_attributeValue != null)
2199 {
2201 }
2202 if (!_isXmlnsAttribute)
2203 {
2204 StartContent();
2206 EndContent();
2207 }
2208 }
2209
2211 {
2213 }
2214
2215 public override void WriteValue(DateTime value)
2216 {
2217 if (IsClosed)
2218 {
2219 ThrowClosed();
2220 }
2221 FlushBase64();
2222 if (_attributeValue != null)
2223 {
2225 }
2226 if (!_isXmlnsAttribute)
2227 {
2228 StartContent();
2230 EndContent();
2231 }
2232 }
2233
2234 public override void WriteValue(UniqueId value)
2235 {
2236 if (IsClosed)
2237 {
2238 ThrowClosed();
2239 }
2240 if (value == null)
2241 {
2243 }
2244 FlushBase64();
2245 if (_attributeValue != null)
2246 {
2248 }
2249 if (!_isXmlnsAttribute)
2250 {
2251 StartContent();
2253 EndContent();
2254 }
2255 }
2256
2257 public override void WriteValue(Guid value)
2258 {
2259 if (IsClosed)
2260 {
2261 ThrowClosed();
2262 }
2263 FlushBase64();
2264 if (_attributeValue != null)
2265 {
2267 }
2268 if (!_isXmlnsAttribute)
2269 {
2270 StartContent();
2272 EndContent();
2273 }
2274 }
2275
2276 public override void WriteValue(TimeSpan value)
2277 {
2278 if (IsClosed)
2279 {
2280 ThrowClosed();
2281 }
2282 FlushBase64();
2283 if (_attributeValue != null)
2284 {
2286 }
2287 if (!_isXmlnsAttribute)
2288 {
2289 StartContent();
2291 EndContent();
2292 }
2293 }
2294
2295 public override void WriteBinHex(byte[] buffer, int offset, int count)
2296 {
2297 if (IsClosed)
2298 {
2299 ThrowClosed();
2300 }
2302 }
2303
2304 public override void WriteBase64(byte[] buffer, int offset, int count)
2305 {
2306 if (IsClosed)
2307 {
2308 ThrowClosed();
2309 }
2310 if (buffer == null)
2311 {
2313 }
2314 if (offset < 0)
2315 {
2317 }
2318 if (count < 0)
2319 {
2321 }
2322 if (count > buffer.Length - offset)
2323 {
2325 }
2326 if (count <= 0)
2327 {
2328 return;
2329 }
2330 if (_trailByteCount > 0)
2331 {
2333 {
2335 count--;
2336 }
2337 }
2338 int num = _trailByteCount + count;
2339 int num2 = num - num % 3;
2340 if (_trailBytes == null)
2341 {
2342 _trailBytes = new byte[3];
2343 }
2344 if (num2 >= 3)
2345 {
2346 if (_attributeValue != null)
2347 {
2350 }
2351 if (!_isXmlnsAttribute)
2352 {
2353 StartContent();
2355 EndContent();
2356 }
2357 _trailByteCount = num - num2;
2358 if (_trailByteCount > 0)
2359 {
2360 int num3 = offset + count - _trailByteCount;
2361 for (int i = 0; i < _trailByteCount; i++)
2362 {
2363 _trailBytes[i] = buffer[num3++];
2364 }
2365 }
2366 }
2367 else
2368 {
2371 }
2372 }
2373
2374 public override Task WriteBase64Async(byte[] buffer, int offset, int count)
2375 {
2376 if (IsClosed)
2377 {
2378 ThrowClosed();
2379 }
2380 if (buffer == null)
2381 {
2383 }
2384 if (offset < 0)
2385 {
2387 }
2388 if (count < 0)
2389 {
2391 }
2392 if (count > buffer.Length - offset)
2393 {
2395 }
2397 }
2398
2400 {
2401 if (count <= 0)
2402 {
2403 return;
2404 }
2405 if (_trailByteCount > 0)
2406 {
2408 {
2410 count--;
2411 }
2412 }
2415 if (_trailBytes == null)
2416 {
2417 _trailBytes = new byte[3];
2418 }
2419 if (actualByteCount >= 3)
2420 {
2421 if (_attributeValue != null)
2422 {
2425 }
2426 if (!_isXmlnsAttribute)
2427 {
2430 EndContent();
2431 }
2433 if (_trailByteCount > 0)
2434 {
2435 int num = offset + count - _trailByteCount;
2436 for (int i = 0; i < _trailByteCount; i++)
2437 {
2438 _trailBytes[i] = buffer[num++];
2439 }
2440 }
2441 }
2442 else
2443 {
2446 }
2447 }
2448
2468
2469 public override void EndCanonicalization()
2470 {
2471 if (IsClosed)
2472 {
2473 ThrowClosed();
2474 }
2475 if (!Signing)
2476 {
2478 }
2481 }
2482
2484
2485 private void FlushBase64()
2486 {
2487 if (_trailByteCount > 0)
2488 {
2490 }
2491 }
2492
2494 {
2495 if (_trailByteCount <= 0)
2496 {
2497 return Task.CompletedTask;
2498 }
2499 return FlushTrailBytesAsync();
2500 }
2501
2502 private void FlushTrailBytes()
2503 {
2504 if (_attributeValue != null)
2505 {
2507 }
2508 if (!_isXmlnsAttribute)
2509 {
2510 StartContent();
2512 EndContent();
2513 }
2514 _trailByteCount = 0;
2515 }
2516
2531
2532 private void WriteValue(object[] array)
2533 {
2534 FlushBase64();
2535 StartContent();
2537 _inList = true;
2538 for (int i = 0; i < array.Length; i++)
2539 {
2540 if (i != 0)
2541 {
2543 }
2545 }
2546 _inList = false;
2548 EndContent();
2549 }
2550
2551 private void WriteValue(Array array)
2552 {
2553 FlushBase64();
2554 StartContent();
2556 _inList = true;
2557 for (int i = 0; i < array.Length; i++)
2558 {
2559 if (i != 0)
2560 {
2562 }
2563 WritePrimitiveValue(array.GetValue(i));
2564 }
2565 _inList = false;
2567 EndContent();
2568 }
2569
2570 protected void StartArray(int count)
2571 {
2572 FlushBase64();
2573 if (_documentState == DocumentState.Epilog)
2574 {
2576 }
2577 if (_documentState == DocumentState.Document && count > 1 && _depth == 0)
2578 {
2580 }
2581 if (_writeState == WriteState.Attribute)
2582 {
2584 }
2585 AutoComplete(WriteState.Content);
2586 }
2587
2588 protected void EndArray()
2589 {
2590 }
2591
2592 private string GeneratePrefix(string ns, XmlDictionaryString xNs)
2593 {
2594 if (_writeState != WriteState.Element && _writeState != WriteState.Attribute)
2595 {
2597 }
2598 string text = _nsMgr.AddNamespace(ns, xNs);
2599 if (text != null)
2600 {
2601 return text;
2602 }
2603 do
2604 {
2605 int value = _elements[_depth].PrefixId++;
2608 handler.AppendLiteral("d");
2609 handler.AppendFormatted(_depth);
2610 handler.AppendLiteral("p");
2611 handler.AppendFormatted(value);
2612 text = string.Create(invariantCulture, ref handler);
2613 }
2614 while (_nsMgr.LookupNamespace(text) != null);
2616 return text;
2617 }
2618
2623
2624 private void WriteAttributeText(string value)
2625 {
2626 if (_attributeValue.Length == 0)
2627 {
2629 }
2630 else
2631 {
2633 }
2634 }
2635}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Definition Buffer.cs:102
static CultureInfo InvariantCulture
static string XmlOnlyOneRoot
Definition SR.cs:480
static string XmlSpecificBindingNamespace
Definition SR.cs:494
static string XmlProcessingInstructionNotSupported
Definition SR.cs:488
static string XmlOnlyWhitespace
Definition SR.cs:482
static string XmlEmptyNamespaceRequiresNullPrefix
Definition SR.cs:378
static string XmlWriterClosed
Definition SR.cs:512
static string XmlInvalidCommentChars
Definition SR.cs:420
static string XmlUndefinedPrefix
Definition SR.cs:506
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlCanonicalizationStarted
Definition SR.cs:698
static string XmlCanonicalizationNotStarted
Definition SR.cs:700
static string XmlReservedPrefix
Definition SR.cs:490
static string ValueMustBeNonNegative
Definition SR.cs:296
static string InvalidLocalNameEmpty
Definition SR.cs:346
static string XmlInvalidWriteState
Definition SR.cs:450
static string XmlMethodNotSupported
Definition SR.cs:468
static string XmlInvalidDepth
Definition SR.cs:424
static string XmlInvalidPrefixState
Definition SR.cs:436
static string SizeExceedsRemainingBufferSpace
Definition SR.cs:324
static string XmlNestedArraysNotSupported
Definition SR.cs:476
static string XmlPrefixBoundToNamespace
Definition SR.cs:486
static string XmlMissingLowSurrogate
Definition SR.cs:470
static string XmlNoRootElement
Definition SR.cs:478
static string XmlNamespaceNotFound
Definition SR.cs:474
static string XmlInvalidXmlSpace
Definition SR.cs:454
static string XmlIllegalOutsideRoot
Definition SR.cs:414
static string XmlInvalidDeclaration
Definition SR.cs:422
Definition SR.cs:7
unsafe string GetString(byte *bytes, int byteCount)
Definition Encoding.cs:973
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
static Task CompletedTask
Definition Task.cs:1120
void DeclareNamespaces(XmlNodeWriter writer)
void Sign(XmlCanonicalWriter signingWriter)
string AddNamespace(string uri, XmlDictionaryString uriDictionaryString)
void AddNamespace(string prefix, string uri, XmlDictionaryString uriDictionaryString)
void AddNamespaceIfNotDeclared(string prefix, string uri, XmlDictionaryString uriDictionaryString)
void StartContent(char[] chars, int offset, int count)
override Task WriteEndAttributeAsync()
override void WriteEndDocument()
override void WriteValue(DateTime value)
override void WriteString(string value)
override void WriteXmlnsAttribute(string prefix, string ns)
override void WriteString(XmlDictionaryString value)
void WriteAttributeText(string value)
override void WriteStartElement(string prefix, string localName, string namespaceUri)
override void WriteEndElement()
async Task AutoCompleteAsync(WriteState writeState)
override void WriteBinHex(byte[] buffer, int offset, int count)
override void WriteChars(char[] chars, int offset, int count)
override void WriteEndAttribute()
override void WriteRaw(char[] chars, int offset, int count)
override void WriteStartDocument()
override void WriteComment(string text)
async Task WriteEndElementAsyncImpl()
void VerifyWhitespace(string s)
override void WriteSurrogateCharEntity(char lowChar, char highChar)
override void WriteRaw(string value)
override void WriteStartDocument(bool standalone)
readonly NamespaceManager _nsMgr
async Task StartElementAndWriteStartElementAsync(string prefix, string localName, string namespaceUri)
void WriteValue(ulong value)
void StartElement(ref string prefix, string localName, string ns, XmlDictionaryString xNs)
void VerifyWhitespace(char[] chars, int offset, int count)
override void WriteCharEntity(char ch)
void PreStartElementAsyncCheck(string prefix, string localName, string ns, XmlDictionaryString xNs)
async Task WriteBase64AsyncImpl(byte[] buffer, int offset, int count)
void SignScope(XmlCanonicalWriter signingWriter)
override void WriteValue(object value)
override void WriteFullEndElement()
override void WriteValue(UniqueId value)
override void WriteValue(XmlDictionaryString value)
void WritePrimitiveValue(object value)
void AutoComplete(WriteState writeState)
void SetOutput(XmlStreamNodeWriter writer)
override void WriteWhitespace(string whitespace)
override void EndCanonicalization()
override void WriteStartElement(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri)
override Task FlushAsync()
override void WriteValue(bool value)
override void WriteStartAttribute(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri)
override void WriteQualifiedName(XmlDictionaryString localName, XmlDictionaryString namespaceUri)
override void WriteName(string name)
override void WriteValue(decimal value)
override void WriteDocType(string name, string pubid, string sysid, string subset)
XmlStreamNodeWriter _nodeWriter
override void WriteXmlnsAttribute(string prefix, XmlDictionaryString ns)
override void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes)
override void WriteValue(Guid value)
override void WriteEntityRef(string name)
XmlSigningNodeWriter _signingWriter
override void WriteQualifiedName(string localName, string namespaceUri)
override bool CanCanonicalize
async Task< string > StartElementAsync(string prefix, string localName, string ns, XmlDictionaryString xNs)
async Task FlushTrailBytesAsync()
override void WriteValue(string value)
void WriteValue(Array array)
override void WriteValue(TimeSpan value)
static BinHexEncoding BinHexEncoding
override void WriteValue(float value)
override void WriteStartAttribute(string prefix, string localName, string namespaceUri)
override Task WriteStartElementAsync(string prefix, string localName, string namespaceUri)
override Task WriteEndElementAsync()
override void WriteCData(string text)
string GetQualifiedNamePrefix(string namespaceUri, XmlDictionaryString xNs)
override void WriteValue(int value)
override void WriteBase64(byte[] buffer, int offset, int count)
async Task WriteEndAttributeAsyncImpl()
string GeneratePrefix(string ns, XmlDictionaryString xNs)
XmlSigningNodeWriter CreateSigningNodeWriter()
static BinHexEncoding _binhexEncoding
override void WriteValue(double value)
override Task WriteBase64Async(byte[] buffer, int offset, int count)
void StartAttribute([AllowNull] ref string prefix, string localName, string ns, XmlDictionaryString xNs)
override string LookupPrefix(string ns)
static readonly string[] s_prefixes
override void WriteNmToken(string name)
override void WriteValue(long value)
void WriteValue(object[] array)
override void WriteProcessingInstruction(string name, string text)
static string ToString(byte[] buffer, int offset, int count)
static Base64Encoding Base64Encoding
static XmlDictionaryString Empty
void WriteInt64Text(long value)
void WriteUInt64Text(ulong value)
virtual Task WriteEndElementAsync(string prefix, string localName)
void WriteDoubleText(double value)
void WriteBoolText(bool value)
virtual Task WriteEndStartElementAsync(bool isEmpty)
void WriteInt32Text(int value)
void WriteUniqueIdText(UniqueId value)
void WriteText(string value)
virtual Task WriteEndAttributeAsync()
void WriteStartAttribute(string prefix, string localName)
void WriteEndStartElement(bool isEmpty)
void WriteStartElement(string prefix, string localName)
void WriteTimeSpanText(TimeSpan value)
void WriteDateTimeText(DateTime value)
virtual Task WriteBase64TextAsync(byte[] trailBuffer, int trailCount, byte[] buffer, int offset, int count)
void WriteFloatText(float value)
void WriteCharEntity(int ch)
void WriteEscapedText(string value)
void WriteDecimalText(decimal value)
void WriteEndElement(string prefix, string localName)
void WriteBase64Text(byte[] trailBuffer, int trailCount, byte[] buffer, int offset, int count)
void WriteGuidText(Guid value)
void WriteComment(string text)
virtual Task WriteStartElementAsync(string prefix, string localName)
void WriteCData(string text)
void WriteQualifiedName(string prefix, XmlDictionaryString localName)
void SetOutput(XmlNodeWriter writer, Stream stream, bool includeComments, string[] inclusivePrefixes)