Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlTextReaderImpl.cs
Go to the documentation of this file.
5using System.IO;
7using System.Text;
10
11namespace System.Xml;
12
14{
44
45 private enum ParsingMode
46 {
47 Full,
50 }
51
63
64 private enum EntityExpandType
65 {
66 All,
69 }
70
89
90 private sealed class LaterInitParam
91 {
92 public bool useAsync;
93
95
96 public byte[] inputBytes;
97
98 public int inputByteCount;
99
101
102 public string inputUriStr;
103
105
107
109
111 }
112
113 private enum InitInputType
114 {
115 UriString,
116 Stream,
118 Invalid
119 }
120
122 {
124 ReadData,
125 Done
126 }
127
128 private readonly struct ParseTextState
129 {
130 public readonly int outOrChars;
131
132 public readonly char[] chars;
133
134 public readonly int pos;
135
136 public readonly int rcount;
137
138 public readonly int rpos;
139
140 public readonly int orChars;
141
142 public readonly char c;
143
144 public ParseTextState(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
145 {
148 this.pos = pos;
150 this.rpos = rpos;
152 this.c = c;
153 }
154 }
155
156 private enum ParseTextFunction
157 {
158 ParseText,
159 Entity,
160 Surrogate,
161 ReadData,
162 NoValue,
164 }
165
166 private struct ParsingState
167 {
168 internal char[] chars;
169
170 internal int charPos;
171
172 internal int charsUsed;
173
175
176 internal bool appendMode;
177
178 internal Stream stream;
179
180 internal Decoder decoder;
181
182 internal byte[] bytes;
183
184 internal int bytePos;
185
186 internal int bytesUsed;
187
189
190 internal int lineNo;
191
192 internal int lineStartPos;
193
194 internal string baseUriStr;
195
196 internal Uri baseUri;
197
198 internal bool isEof;
199
200 internal bool isStreamEof;
201
203
204 internal int entityId;
205
206 internal bool eolNormalized;
207
209
210 internal int LineNo => lineNo;
211
212 internal int LinePos => charPos - lineStartPos;
213
214 internal void Clear()
215 {
216 chars = null;
217 charPos = 0;
218 charsUsed = 0;
219 encoding = null;
220 stream = null;
221 decoder = null;
222 bytes = null;
223 bytePos = 0;
224 bytesUsed = 0;
225 textReader = null;
226 lineNo = 1;
227 lineStartPos = -1;
228 baseUriStr = string.Empty;
229 baseUri = null;
230 isEof = false;
231 isStreamEof = false;
232 eolNormalized = true;
234 }
235
236 internal void Close(bool closeInput)
237 {
238 if (closeInput)
239 {
240 if (stream != null)
241 {
242 stream.Dispose();
243 }
244 else if (textReader != null)
245 {
247 }
248 }
249 }
250 }
251
252 private sealed class XmlContext
253 {
255
256 internal string xmlLang;
257
258 internal string defaultNamespace;
259
261
262 internal XmlContext()
263 {
264 xmlSpace = XmlSpace.None;
265 xmlLang = string.Empty;
266 defaultNamespace = string.Empty;
267 previousContext = null;
268 }
269
277 }
278
280 {
281 public override string DefaultNamespace => string.Empty;
282
283 public override void PushScope()
284 {
285 }
286
287 public override bool PopScope()
288 {
289 return false;
290 }
291
292 public override void AddNamespace(string prefix, string uri)
293 {
294 }
295
296 public override void RemoveNamespace(string prefix, string uri)
297 {
298 }
299
300 public override IEnumerator GetEnumerator()
301 {
302 return null;
303 }
304
306 {
307 return null;
308 }
309
310 public override string LookupNamespace(string prefix)
311 {
312 return string.Empty;
313 }
314
315 public override string LookupPrefix(string uri)
316 {
317 return null;
318 }
319
320 public override bool HasNamespace(string prefix)
321 {
322 return false;
323 }
324 }
325
327 {
328 private readonly XmlTextReaderImpl _reader;
329
331
333
334 Uri IDtdParserAdapter.BaseUri => _reader.DtdParserProxy_BaseUri;
335
336 bool IDtdParserAdapter.IsEof => _reader.DtdParserProxy_IsEof;
337
338 char[] IDtdParserAdapter.ParsingBuffer => _reader.DtdParserProxy_ParsingBuffer;
339
340 int IDtdParserAdapter.ParsingBufferLength => _reader.DtdParserProxy_ParsingBufferLength;
341
343 {
344 get
345 {
346 return _reader.DtdParserProxy_CurrentPosition;
347 }
348 set
349 {
351 }
352 }
353
354 int IDtdParserAdapter.EntityStackLength => _reader.DtdParserProxy_EntityStackLength;
355
356 bool IDtdParserAdapter.IsEntityEolNormalized => _reader.DtdParserProxy_IsEntityEolNormalized;
357
358 int IDtdParserAdapter.LineNo => _reader.DtdParserProxy_LineNo;
359
360 int IDtdParserAdapter.LineStartPosition => _reader.DtdParserProxy_LineStartPosition;
361
362 bool IDtdParserAdapterWithValidation.DtdValidation => _reader.DtdParserProxy_DtdValidation;
363
365
366 bool IDtdParserAdapterV1.Normalization => _reader.DtdParserProxy_Normalization;
367
368 bool IDtdParserAdapterV1.Namespaces => _reader.DtdParserProxy_Namespaces;
369
370 bool IDtdParserAdapterV1.V1CompatibilityMode => _reader.DtdParserProxy_V1CompatibilityMode;
371
373 {
374 _reader = reader;
375 }
376
378 {
380 }
381
386
391
396
401
406
408 {
409 return _reader.DtdParserProxy_PushEntity(entity, out entityId);
410 }
411
416
417 bool IDtdParserAdapter.PushExternalSubset(string systemId, string publicId)
418 {
419 return _reader.DtdParserProxy_PushExternalSubset(systemId, publicId);
420 }
421
426
432
437
442
447
452
457
462
467
472
473 Task<bool> IDtdParserAdapter.PushExternalSubsetAsync(string systemId, string publicId)
474 {
475 return _reader.DtdParserProxy_PushExternalSubsetAsync(systemId, publicId);
476 }
477 }
478
479 private sealed class NodeData : IComparable
480 {
481 private static volatile NodeData s_None;
482
484
485 internal string localName;
486
487 internal string prefix;
488
489 internal string ns;
490
491 internal string nameWPrefix;
492
493 private string _value;
494
495 private char[] _chars;
496
497 private int _valueStartPos;
498
499 private int _valueLength;
500
502
504
505 internal char quoteChar;
506
507 internal int depth;
508
509 private bool _isEmptyOrDefault;
510
511 internal int entityId;
512
513 internal bool xmlContextPushed;
514
516
517 internal object schemaType;
518
519 internal object typedValue;
520
521 internal static NodeData None
522 {
523 get
524 {
525 if (s_None == null)
526 {
527 s_None = new NodeData();
528 }
529 return s_None;
530 }
531 }
532
533 internal int LineNo => lineInfo.lineNo;
534
535 internal int LinePos => lineInfo.linePos;
536
537 internal bool IsEmptyElement
538 {
539 get
540 {
541 if (type == XmlNodeType.Element)
542 {
543 return _isEmptyOrDefault;
544 }
545 return false;
546 }
547 set
548 {
550 }
551 }
552
553 internal bool IsDefaultAttribute
554 {
555 get
556 {
557 if (type == XmlNodeType.Attribute)
558 {
559 return _isEmptyOrDefault;
560 }
561 return false;
562 }
563 set
564 {
566 }
567 }
568
569 internal bool ValueBuffered => _value == null;
570
571 internal string StringValue
572 {
573 get
574 {
575 if (_value == null)
576 {
578 }
579 return _value;
580 }
581 }
582
583 internal NodeData()
584 {
585 Clear(XmlNodeType.None);
586 xmlContextPushed = false;
587 }
588
589 internal void TrimSpacesInValue()
590 {
591 if (ValueBuffered)
592 {
594 }
595 else
596 {
598 }
599 }
600
601 [MemberNotNull("_value")]
602 [MemberNotNull("nameWPrefix")]
603 [MemberNotNull("localName")]
604 [MemberNotNull("prefix")]
605 [MemberNotNull("ns")]
606 internal void Clear(XmlNodeType type)
607 {
608 this.type = type;
609 ClearName();
610 _value = string.Empty;
611 _valueStartPos = -1;
612 schemaType = null;
613 typedValue = null;
614 }
615
616 [MemberNotNull("localName")]
617 [MemberNotNull("prefix")]
618 [MemberNotNull("ns")]
619 [MemberNotNull("nameWPrefix")]
620 internal void ClearName()
621 {
622 localName = string.Empty;
623 prefix = string.Empty;
624 ns = string.Empty;
625 nameWPrefix = string.Empty;
626 }
627
628 internal void SetLineInfo(int lineNo, int linePos)
629 {
630 lineInfo.Set(lineNo, linePos);
631 }
632
633 internal void SetLineInfo2(int lineNo, int linePos)
634 {
635 lineInfo2.Set(lineNo, linePos);
636 }
637
638 internal void SetValueNode(XmlNodeType type, string value)
639 {
640 this.type = type;
641 ClearName();
642 _value = value;
643 _valueStartPos = -1;
644 }
645
646 internal void SetValueNode(XmlNodeType type, char[] chars, int startPos, int len)
647 {
648 this.type = type;
649 ClearName();
650 _value = null;
651 _chars = chars;
654 }
655
656 internal void SetNamedNode(XmlNodeType type, string localName)
657 {
659 }
660
661 internal void SetNamedNode(XmlNodeType type, string localName, string prefix, string nameWPrefix)
662 {
663 this.type = type;
667 ns = string.Empty;
668 _value = string.Empty;
669 _valueStartPos = -1;
670 }
671
672 internal void SetValue(string value)
673 {
674 _valueStartPos = -1;
675 _value = value;
676 }
677
678 internal void SetValue(char[] chars, int startPos, int len)
679 {
680 _value = null;
681 _chars = chars;
684 }
685
686 internal void OnBufferInvalidated()
687 {
688 if (_value == null)
689 {
691 }
692 _valueStartPos = -1;
693 }
694
695 internal void CopyTo(int valueOffset, StringBuilder sb)
696 {
697 if (_value == null)
698 {
700 }
701 else if (valueOffset <= 0)
702 {
703 sb.Append(_value);
704 }
705 else
706 {
708 }
709 }
710
711 internal int CopyTo(int valueOffset, char[] buffer, int offset, int length)
712 {
713 if (_value == null)
714 {
715 int num = _valueLength - valueOffset;
716 if (num > length)
717 {
718 num = length;
719 }
721 return num;
722 }
724 if (num2 > length)
725 {
726 num2 = length;
727 }
729 return num2;
730 }
731
733 {
734 if (_value == null)
735 {
737 }
738 return decoder.Decode(_value, valueOffset, _value.Length - valueOffset);
739 }
740
755
757 {
758 if (nameWPrefix != null)
759 {
760 return nameWPrefix;
761 }
762 return CreateNameWPrefix(nt);
763 }
764
766 {
767 if (prefix.Length == 0)
768 {
770 }
771 else
772 {
773 nameWPrefix = nt.Add(prefix + ":" + localName);
774 }
775 return nameWPrefix;
776 }
777
779 {
781 {
782 if (Ref.Equal(localName, nodeData.localName))
783 {
784 if (Ref.Equal(ns, nodeData.ns))
785 {
786 return 0;
787 }
788 return string.CompareOrdinal(ns, nodeData.ns);
789 }
790 return string.CompareOrdinal(localName, nodeData.localName);
791 }
792 return 1;
793 }
794 }
795
797 {
799
801
802 public int Compare(object x, object y)
803 {
804 if (x == null)
805 {
806 if (y != null)
807 {
808 return -1;
809 }
810 return 0;
811 }
812 if (y == null)
813 {
814 return 1;
815 }
816 string localName;
817 string prefix;
818 if (x is NodeData nodeData)
819 {
820 localName = nodeData.localName;
821 prefix = nodeData.prefix;
822 }
823 else
824 {
826 {
827 throw new XmlException(System.SR.Xml_DefaultException, string.Empty);
828 }
829 localName = dtdDefaultAttributeInfo.LocalName;
831 }
832 string localName2;
833 string prefix2;
834 if (y is NodeData nodeData2)
835 {
836 localName2 = nodeData2.localName;
837 prefix2 = nodeData2.prefix;
838 }
839 else
840 {
842 {
843 throw new XmlException(System.SR.Xml_DefaultException, string.Empty);
844 }
847 }
848 int num = string.Compare(localName, localName2, StringComparison.Ordinal);
849 if (num != 0)
850 {
851 return num;
852 }
853 return string.Compare(prefix, prefix2, StringComparison.Ordinal);
854 }
855 }
856
858
860
861 private readonly bool _useAsync;
862
864
866
868
870
872
873 private NodeData[] _nodes;
874
876
877 private int _index;
878
879 private int _curAttrIndex = -1;
880
881 private int _attrCount;
882
883 private int _attrHashtable;
884
886
888
889 private bool _fullAttrCleanup;
890
892
894
896
898
899 private readonly string _url = string.Empty;
900
901 private bool _normalize;
902
903 private bool _supportNamespaces = true;
904
906
908
910
911 private readonly bool _ignorePIs;
912
913 private readonly bool _ignoreComments;
914
915 private readonly bool _checkCharacters;
916
917 private readonly int _lineNumberOffset;
918
919 private readonly int _linePositionOffset;
920
921 private readonly bool _closeInput;
922
923 private readonly long _maxCharactersInDocument;
924
925 private readonly long _maxCharactersFromEntities;
926
927 private readonly bool _v1Compat;
928
930
931 private string _lastPrefix = string.Empty;
932
934
936
937 private int _parsingStatesStackTop = -1;
938
939 private string _reportedBaseUri = string.Empty;
940
942
944
946
948
949 private bool _fragment;
950
952
954
956
958
960
961 private int _incReadDepth;
962
964
966
968
970
972
974
975 private OnDefaultAttributeUseDelegate _onDefaultAttributeUse;
976
978
980
982
983 private bool _rootElementParsed;
984
985 private bool _standalone;
986
987 private int _nextEntityId = 1;
988
990
992
994
995 private bool _afterResetState;
996
998
999 private int _readValueOffset;
1000
1002
1004
1006
1008
1010
1011 private bool _xmlResolverIsSet;
1012
1013 private readonly string _xml;
1014
1015 private readonly string _xmlNs;
1016
1018
1020
1022
1023 private readonly Task<(int, int, int, bool)> _parseText_dummyTask = Task.FromResult((0, 0, 0, false));
1024
1026
1062
1063 public override XmlNodeType NodeType => _curNode.type;
1064
1065 public override string Name => _curNode.GetNameWPrefix(_nameTable);
1066
1067 public override string LocalName => _curNode.localName;
1068
1069 public override string NamespaceURI => _curNode.ns ?? string.Empty;
1070
1071 public override string Prefix => _curNode.prefix;
1072
1073 public override string Value
1074 {
1075 get
1076 {
1077 if (_parsingFunction >= ParsingFunction.PartialTextValue)
1078 {
1079 if (_parsingFunction == ParsingFunction.PartialTextValue)
1080 {
1083 }
1084 else
1085 {
1087 }
1088 }
1089 return _curNode.StringValue;
1090 }
1091 }
1092
1093 public override int Depth => _curNode.depth;
1094
1095 public override string BaseURI => _reportedBaseUri;
1096
1097 public override bool IsEmptyElement => _curNode.IsEmptyElement;
1098
1099 public override bool IsDefault => _curNode.IsDefaultAttribute;
1100
1101 public override char QuoteChar
1102 {
1103 get
1104 {
1105 if (_curNode.type != XmlNodeType.Attribute)
1106 {
1107 return '"';
1108 }
1109 return _curNode.quoteChar;
1110 }
1111 }
1112
1113 public override XmlSpace XmlSpace => _xmlContext.xmlSpace;
1114
1115 public override string XmlLang => _xmlContext.xmlLang;
1116
1117 public override ReadState ReadState => _readState;
1118
1119 public override bool EOF => _parsingFunction == ParsingFunction.Eof;
1120
1121 public override XmlNameTable NameTable => _nameTable;
1122
1123 public override bool CanResolveEntity => true;
1124
1125 public override int AttributeCount => _attrCount;
1126
1127 internal XmlReader OuterReader
1128 {
1129 set
1130 {
1132 }
1133 }
1134
1135 public override bool CanReadBinaryContent => true;
1136
1137 public override bool CanReadValueChunk => true;
1138
1139 public int LineNumber => _curNode.LineNo;
1140
1141 public int LinePosition => _curNode.LinePos;
1142
1143 internal bool Namespaces
1144 {
1145 get
1146 {
1147 return _supportNamespaces;
1148 }
1149 set
1150 {
1151 if (_readState != 0)
1152 {
1154 }
1156 if (value)
1157 {
1158 if (_namespaceManager is NoNamespaceManager)
1159 {
1161 {
1163 }
1164 else
1165 {
1167 }
1168 }
1170 }
1171 else
1172 {
1173 if (!(_namespaceManager is NoNamespaceManager))
1174 {
1175 _namespaceManager = new NoNamespaceManager();
1176 }
1177 _xmlContext.defaultNamespace = string.Empty;
1178 }
1179 }
1180 }
1181
1182 internal bool Normalization
1183 {
1184 get
1185 {
1186 return _normalize;
1187 }
1188 set
1189 {
1190 if (_readState == ReadState.Closed)
1191 {
1193 }
1194 _normalize = value;
1195 if (_ps.entity == null || _ps.entity.IsExternal)
1196 {
1198 }
1199 }
1200 }
1201
1202 internal Encoding Encoding
1203 {
1204 get
1205 {
1206 if (_readState != ReadState.Interactive)
1207 {
1208 return null;
1209 }
1210 return _reportedEncoding;
1211 }
1212 }
1213
1214 internal WhitespaceHandling WhitespaceHandling
1215 {
1216 get
1217 {
1218 return _whitespaceHandling;
1219 }
1220 set
1221 {
1222 if (_readState == ReadState.Closed)
1223 {
1225 }
1226 if ((uint)value > 2u)
1227 {
1228 throw new XmlException(System.SR.Xml_WhitespaceHandling, string.Empty);
1229 }
1231 }
1232 }
1233
1234 internal DtdProcessing DtdProcessing
1235 {
1236 get
1237 {
1238 return _dtdProcessing;
1239 }
1240 set
1241 {
1242 if ((uint)value > 2u)
1243 {
1244 throw new ArgumentOutOfRangeException("value");
1245 }
1247 }
1248 }
1249
1250 internal EntityHandling EntityHandling
1251 {
1252 get
1253 {
1254 return _entityHandling;
1255 }
1256 set
1257 {
1258 if (value != EntityHandling.ExpandEntities && value != EntityHandling.ExpandCharEntities)
1259 {
1260 throw new XmlException(System.SR.Xml_EntityHandling, string.Empty);
1261 }
1263 }
1264 }
1265
1266 internal bool IsResolverSet => _xmlResolverIsSet;
1267
1268 internal XmlResolver XmlResolver
1269 {
1270 set
1271 {
1273 _xmlResolverIsSet = true;
1274 _ps.baseUri = null;
1275 for (int i = 0; i <= _parsingStatesStackTop; i++)
1276 {
1278 }
1279 }
1280 }
1281
1283
1285
1286 internal bool DtdParserProxy_DtdValidation => DtdValidation;
1287
1289
1291
1293
1294 internal Uri DtdParserProxy_BaseUri
1295 {
1296 get
1297 {
1298 if (_ps.baseUriStr.Length > 0 && _ps.baseUri == null && _xmlResolver != null)
1299 {
1301 }
1302 return _ps.baseUri;
1303 }
1304 }
1305
1306 internal bool DtdParserProxy_IsEof => _ps.isEof;
1307
1308 internal char[] DtdParserProxy_ParsingBuffer => _ps.chars;
1309
1311
1313 {
1314 get
1315 {
1316 return _ps.charPos;
1317 }
1318 set
1319 {
1321 }
1322 }
1323
1325
1327
1329
1330 internal int DtdParserProxy_LineNo => _ps.LineNo;
1331
1333
1334 private bool IsResolverNull
1335 {
1336 get
1337 {
1338 if (_xmlResolver != null)
1339 {
1340 return !_xmlResolverIsSet;
1341 }
1342 return true;
1343 }
1344 }
1345
1346 private bool InAttributeValueIterator
1347 {
1348 get
1349 {
1350 if (_attrCount > 0)
1351 {
1352 return _parsingFunction >= ParsingFunction.InReadAttributeValue;
1353 }
1354 return false;
1355 }
1356 }
1357
1358 private bool DtdValidation => _validationEventHandling != null;
1359
1360 private bool InEntity => _parsingStatesStackTop >= 0;
1361
1362 internal override IDtdInfo DtdInfo => _dtdInfo;
1363
1364 internal IValidationEventHandling ValidationEventHandling
1365 {
1366 set
1367 {
1369 }
1370 }
1371
1372 internal OnDefaultAttributeUseDelegate OnDefaultAttributeUse
1373 {
1374 set
1375 {
1377 }
1378 }
1379
1380 internal bool XmlValidatingReaderCompatibilityMode
1381 {
1382 set
1383 {
1385 if (value)
1386 {
1387 _nameTable.Add("http://www.w3.org/2001/XMLSchema");
1388 _nameTable.Add("http://www.w3.org/2001/XMLSchema-instance");
1389 _nameTable.Add("urn:schemas-microsoft-com:datatypes");
1390 }
1391 }
1392 }
1393
1395
1396 internal object InternalSchemaType
1397 {
1398 get
1399 {
1400 return _curNode.schemaType;
1401 }
1402 set
1403 {
1405 }
1406 }
1407
1408 internal object InternalTypedValue
1409 {
1410 get
1411 {
1412 return _curNode.typedValue;
1413 }
1414 set
1415 {
1417 }
1418 }
1419
1420 internal bool StandAlone => _standalone;
1421
1423
1424 internal bool V1Compat => _v1Compat;
1425
1427 {
1428 get
1429 {
1430 if (_fragmentType != XmlNodeType.Element)
1431 {
1432 return ConformanceLevel.Document;
1433 }
1434 return ConformanceLevel.Fragment;
1435 }
1436 }
1437
1439 {
1440 set
1441 {
1443 }
1444 }
1445
1447 {
1449 _outerReader = this;
1450 _xmlContext = new XmlContext();
1451 _nameTable = new NameTable();
1452 _nodes = new NodeData[8];
1453 _nodes[0] = new NodeData();
1454 _curNode = _nodes[0];
1456 _xml = _nameTable.Add("xml");
1457 _xmlNs = _nameTable.Add("xmlns");
1458 }
1459
1461 {
1462 _v1Compat = true;
1463 _outerReader = this;
1464 _nameTable = nt;
1465 nt.Add(string.Empty);
1466 _xmlResolver = null;
1467 _xml = nt.Add("xml");
1468 _xmlNs = nt.Add("xmlns");
1469 _nodes = new NodeData[8];
1470 _nodes[0] = new NodeData();
1471 _curNode = _nodes[0];
1473 _xmlContext = new XmlContext();
1474 _parsingFunction = ParsingFunction.SwitchToInteractiveXmlDecl;
1475 _nextParsingFunction = ParsingFunction.DocumentContent;
1476 _entityHandling = EntityHandling.ExpandCharEntities;
1478 _closeInput = true;
1480 _maxCharactersFromEntities = 10000000L;
1483 _ps.lineNo = 1;
1484 _ps.lineStartPos = -1;
1485 }
1486
1488 {
1489 _useAsync = settings.Async;
1490 _v1Compat = false;
1491 _outerReader = this;
1492 _xmlContext = new XmlContext();
1494 if (context == null)
1495 {
1496 if (xmlNameTable == null)
1497 {
1498 xmlNameTable = new NameTable();
1499 }
1500 else
1501 {
1503 }
1506 }
1507 else
1508 {
1509 SetupFromParserContext(context, settings);
1511 }
1512 xmlNameTable.Add(string.Empty);
1513 _xml = xmlNameTable.Add("xml");
1514 _xmlNs = xmlNameTable.Add("xmlns");
1516 _nodes = new NodeData[8];
1517 _nodes[0] = new NodeData();
1518 _curNode = _nodes[0];
1520 _entityHandling = EntityHandling.ExpandEntities;
1523 _normalize = true;
1532 _dtdProcessing = settings.DtdProcessing;
1537 _fragmentParserContext = context;
1538 _parsingFunction = ParsingFunction.SwitchToInteractiveXmlDecl;
1539 _nextParsingFunction = ParsingFunction.DocumentContent;
1540 switch (settings.ConformanceLevel)
1541 {
1542 case ConformanceLevel.Auto:
1544 _fragment = true;
1545 break;
1546 case ConformanceLevel.Fragment:
1547 _fragmentType = XmlNodeType.Element;
1548 _fragment = true;
1549 break;
1550 default:
1551 _fragmentType = XmlNodeType.Document;
1552 break;
1553 }
1554 }
1555
1558 {
1559 }
1560
1562 : this(string.Empty, input, nt)
1563 {
1564 }
1565
1567 : this(url, input, new NameTable())
1568 {
1569 }
1570
1572 : this(nt)
1573 {
1575 if (url == null || url.Length == 0)
1576 {
1577 InitStreamInput(input, null);
1578 }
1579 else
1580 {
1581 InitStreamInput(url, input, null);
1582 }
1585 }
1586
1589 {
1590 }
1591
1596
1598 : this(url, input, new NameTable())
1599 {
1600 }
1601
1603 : this(nt)
1604 {
1606 _reportedBaseUri = ((url != null) ? url : string.Empty);
1609 }
1610
1612 : this((context != null && context.NameTable != null) ? context.NameTable : new NameTable())
1613 {
1614 Encoding encoding = context?.Encoding;
1615 if (context == null || context.BaseURI == null || context.BaseURI.Length == 0)
1616 {
1617 InitStreamInput(xmlFragment, encoding);
1618 }
1619 else
1620 {
1621 InitStreamInput(GetTempResolver().ResolveUri(null, context.BaseURI), xmlFragment, encoding);
1622 }
1626 }
1627
1629 : this((context == null || context.NameTable == null) ? new NameTable() : context.NameTable)
1630 {
1631 if (xmlFragment == null)
1632 {
1633 xmlFragment = string.Empty;
1634 }
1635 if (context == null)
1636 {
1638 }
1639 else
1640 {
1641 _reportedBaseUri = context.BaseURI;
1643 }
1646 }
1647
1649 : this((context == null || context.NameTable == null) ? new NameTable() : context.NameTable)
1650 {
1651 InitStringInput((context == null) ? string.Empty : context.BaseURI, Encoding.Unicode, "<?xml " + xmlFragment + "?>");
1652 InitFragmentReader(XmlNodeType.XmlDeclaration, context, allowXmlDeclFragment: true);
1653 }
1654
1655 public XmlTextReaderImpl(string url)
1656 : this(url, new NameTable())
1657 {
1658 }
1659
1661 : this(nt)
1662 {
1663 if (url == null)
1664 {
1665 throw new ArgumentNullException("url");
1666 }
1667 if (url.Length == 0)
1668 {
1669 throw new ArgumentException(System.SR.Xml_EmptyUrl, "url");
1670 }
1672 _url = url;
1677 }
1678
1680 : this(settings.GetXmlResolver(), settings, context)
1681 {
1682 Uri uri = uriResolver.ResolveUri(null, uriStr);
1683 string text = uri.ToString();
1684 if (context != null && context.BaseURI != null && context.BaseURI.Length > 0 && !UriEqual(uri, text, context.BaseURI, settings.GetXmlResolver()))
1685 {
1686 if (text.Length > 0)
1687 {
1689 }
1690 text = context.BaseURI;
1691 }
1693 _closeInput = true;
1700 if (!settings.Async)
1701 {
1703 }
1704 else
1705 {
1707 }
1708 }
1709
1710 private void FinishInitUriString()
1711 {
1712 Stream stream = null;
1714 {
1716 stream = (Stream)entityAsync.GetAwaiter().GetResult();
1717 }
1718 else
1719 {
1721 }
1722 if (stream == null)
1723 {
1725 }
1726 Encoding encoding = null;
1727 if (_laterInitParam.inputContext != null)
1728 {
1730 }
1731 try
1732 {
1736 {
1738 }
1739 }
1740 catch
1741 {
1742 stream.Dispose();
1743 throw;
1744 }
1745 _laterInitParam = null;
1746 }
1747
1748 internal XmlTextReaderImpl(Stream stream, byte[] bytes, int byteCount, XmlReaderSettings settings, Uri baseUri, string baseUriStr, XmlParserContext context, bool closeInput)
1749 : this(settings.GetXmlResolver(), settings, context)
1750 {
1751 if (context != null && context.BaseURI != null && context.BaseURI.Length > 0 && !UriEqual(baseUri, baseUriStr, context.BaseURI, settings.GetXmlResolver()))
1752 {
1753 if (baseUriStr.Length > 0)
1754 {
1756 }
1757 baseUriStr = context.BaseURI;
1758 }
1759 _reportedBaseUri = baseUriStr ?? string.Empty;
1768 if (!settings.Async)
1769 {
1771 }
1772 else
1773 {
1775 }
1776 }
1777
1793
1794 internal XmlTextReaderImpl(TextReader input, XmlReaderSettings settings, string baseUriStr, XmlParserContext context)
1795 : this(settings.GetXmlResolver(), settings, context)
1796 {
1797 if (context != null && context.BaseURI != null)
1798 {
1799 baseUriStr = context.BaseURI;
1800 }
1801 _reportedBaseUri = baseUriStr;
1802 _closeInput = settings.CloseInput;
1807 if (!settings.Async)
1808 {
1810 }
1811 else
1812 {
1814 }
1815 }
1816
1827
1829 : this(null, settings, context)
1830 {
1834 }
1835
1836 public override string GetAttribute(string name)
1837 {
1838 int num = (name.Contains(':') ? GetIndexOfAttributeWithPrefix(name) : GetIndexOfAttributeWithoutPrefix(name));
1839 if (num < 0)
1840 {
1841 return null;
1842 }
1843 return _nodes[num].StringValue;
1844 }
1845
1846 public override string GetAttribute(string localName, string namespaceURI)
1847 {
1848 namespaceURI = ((namespaceURI == null) ? string.Empty : _nameTable.Get(namespaceURI));
1849 string strB = _nameTable.Get(localName);
1850 for (int i = _index + 1; i < _index + _attrCount + 1; i++)
1851 {
1853 {
1854 return _nodes[i].StringValue;
1855 }
1856 }
1857 return null;
1858 }
1859
1860 public override string GetAttribute(int i)
1861 {
1863 {
1864 throw new ArgumentOutOfRangeException("i");
1865 }
1866 return _nodes[_index + i + 1].StringValue;
1867 }
1868
1869 public override bool MoveToAttribute(string name)
1870 {
1871 int num = (name.Contains(':') ? GetIndexOfAttributeWithPrefix(name) : GetIndexOfAttributeWithoutPrefix(name));
1872 if (num >= 0)
1873 {
1875 {
1877 }
1878 _curAttrIndex = num - _index - 1;
1879 _curNode = _nodes[num];
1880 return true;
1881 }
1882 return false;
1883 }
1884
1885 public override bool MoveToAttribute(string localName, string namespaceURI)
1886 {
1887 string strB = ((namespaceURI == null) ? string.Empty : _nameTable.Get(namespaceURI));
1888 string strB2 = _nameTable.Get(localName);
1889 for (int i = _index + 1; i < _index + _attrCount + 1; i++)
1890 {
1891 if (Ref.Equal(_nodes[i].localName, strB2) && Ref.Equal(_nodes[i].ns, strB))
1892 {
1893 _curAttrIndex = i - _index - 1;
1894 _curNode = _nodes[i];
1896 {
1898 }
1899 return true;
1900 }
1901 }
1902 return false;
1903 }
1904
1905 public override void MoveToAttribute(int i)
1906 {
1908 {
1909 throw new ArgumentOutOfRangeException("i");
1910 }
1912 {
1914 }
1915 _curAttrIndex = i;
1917 }
1918
1919 public override bool MoveToFirstAttribute()
1920 {
1921 if (_attrCount == 0)
1922 {
1923 return false;
1924 }
1926 {
1928 }
1929 _curAttrIndex = 0;
1930 _curNode = _nodes[_index + 1];
1931 return true;
1932 }
1933
1934 public override bool MoveToNextAttribute()
1935 {
1936 if (_curAttrIndex + 1 < _attrCount)
1937 {
1939 {
1941 }
1943 return true;
1944 }
1945 return false;
1946 }
1947
1948 public override bool MoveToElement()
1949 {
1951 {
1953 }
1954 else if (_curNode.type != XmlNodeType.Attribute)
1955 {
1956 return false;
1957 }
1958 _curAttrIndex = -1;
1960 return true;
1961 }
1962
1963 private void FinishInit()
1964 {
1965 switch (_laterInitParam.initType)
1966 {
1967 case InitInputType.UriString:
1969 break;
1970 case InitInputType.Stream:
1972 break;
1973 case InitInputType.TextReader:
1975 break;
1976 }
1977 }
1978
1979 public override bool Read()
1980 {
1981 if (_laterInitParam != null)
1982 {
1983 FinishInit();
1984 }
1985 while (true)
1986 {
1987 switch (_parsingFunction)
1988 {
1989 case ParsingFunction.ElementContent:
1990 return ParseElementContent();
1991 case ParsingFunction.DocumentContent:
1992 return ParseDocumentContent();
1993 case ParsingFunction.OpenUrl:
1994 OpenUrl();
1995 goto case ParsingFunction.SwitchToInteractiveXmlDecl;
1996 case ParsingFunction.SwitchToInteractive:
1997 _readState = ReadState.Interactive;
1999 break;
2000 case ParsingFunction.SwitchToInteractiveXmlDecl:
2001 _readState = ReadState.Interactive;
2003 if (ParseXmlDeclaration(isTextDecl: false))
2004 {
2006 return true;
2007 }
2009 break;
2010 case ParsingFunction.ResetAttributesRootLevel:
2013 _parsingFunction = ((_index == 0) ? ParsingFunction.DocumentContent : ParsingFunction.ElementContent);
2014 break;
2015 case ParsingFunction.MoveToElementContent:
2017 _index++;
2019 _parsingFunction = ParsingFunction.ElementContent;
2020 break;
2021 case ParsingFunction.PopElementContext:
2024 break;
2025 case ParsingFunction.PopEmptyElementContext:
2031 break;
2032 case ParsingFunction.EntityReference:
2035 return true;
2036 case ParsingFunction.ReportEndEntity:
2039 return true;
2040 case ParsingFunction.AfterResolveEntityInContent:
2045 break;
2046 case ParsingFunction.AfterResolveEmptyEntityInContent:
2048 _curNode.SetValueNode(XmlNodeType.Text, string.Empty);
2053 return true;
2054 case ParsingFunction.InReadAttributeValue:
2057 break;
2058 case ParsingFunction.InIncrementalRead:
2060 return true;
2061 case ParsingFunction.FragmentAttribute:
2062 return ParseFragmentAttribute();
2063 case ParsingFunction.XmlDeclarationFragment:
2066 return true;
2067 case ParsingFunction.GoToEof:
2068 OnEof();
2069 return false;
2070 case ParsingFunction.Error:
2071 case ParsingFunction.Eof:
2072 case ParsingFunction.ReaderClosed:
2073 return false;
2074 case ParsingFunction.NoData:
2076 return false;
2077 case ParsingFunction.PartialTextValue:
2079 break;
2080 case ParsingFunction.InReadValueChunk:
2082 break;
2083 case ParsingFunction.InReadContentAsBinary:
2085 break;
2086 case ParsingFunction.InReadElementContentAsBinary:
2088 break;
2089 }
2090 }
2091 }
2092
2093 public override void Close()
2094 {
2096 }
2097
2098 public override void Skip()
2099 {
2100 if (_readState != ReadState.Interactive)
2101 {
2102 return;
2103 }
2105 {
2108 }
2109 else
2110 {
2111 switch (_parsingFunction)
2112 {
2113 case ParsingFunction.InIncrementalRead:
2115 break;
2116 case ParsingFunction.PartialTextValue:
2118 break;
2119 case ParsingFunction.InReadValueChunk:
2121 break;
2122 case ParsingFunction.InReadContentAsBinary:
2124 break;
2125 case ParsingFunction.InReadElementContentAsBinary:
2127 break;
2128 }
2129 }
2131 if (type != XmlNodeType.Element)
2132 {
2133 if (type != XmlNodeType.Attribute)
2134 {
2135 goto IL_00dc;
2136 }
2138 }
2140 {
2141 int index = _index;
2142 _parsingMode = ParsingMode.SkipContent;
2143 while (_outerReader.Read() && _index > index)
2144 {
2145 }
2147 }
2148 goto IL_00dc;
2149 IL_00dc:
2151 }
2152
2153 public override string LookupNamespace(string prefix)
2154 {
2155 if (!_supportNamespaces)
2156 {
2157 return null;
2158 }
2160 }
2161
2162 public override bool ReadAttributeValue()
2163 {
2164 if (_parsingFunction != ParsingFunction.InReadAttributeValue)
2165 {
2166 if (_curNode.type != XmlNodeType.Attribute)
2167 {
2168 return false;
2169 }
2170 if (_readState != ReadState.Interactive || _curAttrIndex < 0)
2171 {
2172 return false;
2173 }
2174 if (_parsingFunction == ParsingFunction.InReadValueChunk)
2175 {
2177 }
2178 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
2179 {
2181 }
2182 if (_curNode.nextAttrValueChunk == null || _entityHandling == EntityHandling.ExpandEntities)
2183 {
2185 nodeData.SetValueNode(XmlNodeType.Text, _curNode.StringValue);
2190 }
2191 else
2192 {
2194 AddNode(_index + _attrCount + 1, _index + 2);
2196 _fullAttrCleanup = true;
2197 }
2199 _parsingFunction = ParsingFunction.InReadAttributeValue;
2201 return true;
2202 }
2204 {
2205 if (_curNode.nextAttrValueChunk != null)
2206 {
2209 return true;
2210 }
2211 return false;
2212 }
2213 return ParseAttributeValueChunk();
2214 }
2215
2216 public override void ResolveEntity()
2217 {
2218 if (_curNode.type != XmlNodeType.EntityReference)
2219 {
2221 }
2222 if (_parsingFunction == ParsingFunction.InReadAttributeValue || _parsingFunction == ParsingFunction.FragmentAttribute)
2223 {
2225 {
2226 case EntityType.Expanded:
2227 case EntityType.ExpandedInAttribute:
2228 if (_ps.charsUsed - _ps.charPos == 0)
2229 {
2231 }
2232 break;
2233 case EntityType.FakeExpanded:
2235 break;
2236 default:
2237 throw new XmlException(System.SR.Xml_InternalError, string.Empty);
2238 }
2239 }
2240 else
2241 {
2243 {
2244 case EntityType.Expanded:
2245 case EntityType.ExpandedInAttribute:
2247 if (_ps.charsUsed - _ps.charPos == 0 && !_ps.entity.IsExternal)
2248 {
2249 _parsingFunction = ParsingFunction.AfterResolveEmptyEntityInContent;
2250 }
2251 else
2252 {
2253 _parsingFunction = ParsingFunction.AfterResolveEntityInContent;
2254 }
2255 break;
2256 case EntityType.FakeExpanded:
2258 _parsingFunction = ParsingFunction.AfterResolveEmptyEntityInContent;
2259 break;
2260 default:
2261 throw new XmlException(System.SR.Xml_InternalError, string.Empty);
2262 }
2263 }
2265 _index++;
2266 }
2267
2269 {
2270 if (_outerReader.NodeType == XmlNodeType.EntityReference && _parsingFunction == ParsingFunction.AfterResolveEntityInContent && !_outerReader.Read())
2271 {
2273 }
2274 }
2275
2276 public override string ReadString()
2277 {
2279 return base.ReadString();
2280 }
2281
2282 public override int ReadContentAsBase64(byte[] buffer, int index, int count)
2283 {
2284 if (buffer == null)
2285 {
2286 throw new ArgumentNullException("buffer");
2287 }
2288 if (count < 0)
2289 {
2290 throw new ArgumentOutOfRangeException("count");
2291 }
2292 if (index < 0)
2293 {
2294 throw new ArgumentOutOfRangeException("index");
2295 }
2296 if (buffer.Length - index < count)
2297 {
2298 throw new ArgumentOutOfRangeException("count");
2299 }
2300 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
2301 {
2303 {
2305 }
2306 }
2307 else
2308 {
2309 if (_readState != ReadState.Interactive)
2310 {
2311 return 0;
2312 }
2313 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
2314 {
2316 }
2318 {
2319 throw CreateReadContentAsException("ReadContentAsBase64");
2320 }
2322 {
2323 return 0;
2324 }
2325 }
2328 }
2329
2330 public override int ReadContentAsBinHex(byte[] buffer, int index, int count)
2331 {
2332 if (buffer == null)
2333 {
2334 throw new ArgumentNullException("buffer");
2335 }
2336 if (count < 0)
2337 {
2338 throw new ArgumentOutOfRangeException("count");
2339 }
2340 if (index < 0)
2341 {
2342 throw new ArgumentOutOfRangeException("index");
2343 }
2344 if (buffer.Length - index < count)
2345 {
2346 throw new ArgumentOutOfRangeException("count");
2347 }
2348 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
2349 {
2351 {
2353 }
2354 }
2355 else
2356 {
2357 if (_readState != ReadState.Interactive)
2358 {
2359 return 0;
2360 }
2361 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
2362 {
2364 }
2366 {
2367 throw CreateReadContentAsException("ReadContentAsBinHex");
2368 }
2370 {
2371 return 0;
2372 }
2373 }
2376 }
2377
2378 public override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
2379 {
2380 if (buffer == null)
2381 {
2382 throw new ArgumentNullException("buffer");
2383 }
2384 if (count < 0)
2385 {
2386 throw new ArgumentOutOfRangeException("count");
2387 }
2388 if (index < 0)
2389 {
2390 throw new ArgumentOutOfRangeException("index");
2391 }
2392 if (buffer.Length - index < count)
2393 {
2394 throw new ArgumentOutOfRangeException("count");
2395 }
2396 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
2397 {
2399 {
2401 }
2402 }
2403 else
2404 {
2405 if (_readState != ReadState.Interactive)
2406 {
2407 return 0;
2408 }
2409 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
2410 {
2412 }
2413 if (_curNode.type != XmlNodeType.Element)
2414 {
2415 throw CreateReadElementContentAsException("ReadElementContentAsBinHex");
2416 }
2418 {
2419 return 0;
2420 }
2421 }
2424 }
2425
2426 public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
2427 {
2428 if (buffer == null)
2429 {
2430 throw new ArgumentNullException("buffer");
2431 }
2432 if (count < 0)
2433 {
2434 throw new ArgumentOutOfRangeException("count");
2435 }
2436 if (index < 0)
2437 {
2438 throw new ArgumentOutOfRangeException("index");
2439 }
2440 if (buffer.Length - index < count)
2441 {
2442 throw new ArgumentOutOfRangeException("count");
2443 }
2444 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
2445 {
2447 {
2449 }
2450 }
2451 else
2452 {
2453 if (_readState != ReadState.Interactive)
2454 {
2455 return 0;
2456 }
2457 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
2458 {
2460 }
2461 if (_curNode.type != XmlNodeType.Element)
2462 {
2463 throw CreateReadElementContentAsException("ReadElementContentAsBinHex");
2464 }
2466 {
2467 return 0;
2468 }
2469 }
2472 }
2473
2474 public override int ReadValueChunk(char[] buffer, int index, int count)
2475 {
2477 {
2479 }
2480 if (buffer == null)
2481 {
2482 throw new ArgumentNullException("buffer");
2483 }
2484 if (count < 0)
2485 {
2486 throw new ArgumentOutOfRangeException("count");
2487 }
2488 if (index < 0)
2489 {
2490 throw new ArgumentOutOfRangeException("index");
2491 }
2492 if (buffer.Length - index < count)
2493 {
2494 throw new ArgumentOutOfRangeException("count");
2495 }
2496 if (_parsingFunction != ParsingFunction.InReadValueChunk)
2497 {
2498 if (_readState != ReadState.Interactive)
2499 {
2500 return 0;
2501 }
2502 if (_parsingFunction == ParsingFunction.PartialTextValue)
2503 {
2504 _incReadState = IncrementalReadState.ReadValueChunk_OnPartialValue;
2505 }
2506 else
2507 {
2508 _incReadState = IncrementalReadState.ReadValueChunk_OnCachedValue;
2511 }
2512 _parsingFunction = ParsingFunction.InReadValueChunk;
2513 _readValueOffset = 0;
2514 }
2515 if (count == 0)
2516 {
2517 return 0;
2518 }
2519 int num = 0;
2520 int num2 = _curNode.CopyTo(_readValueOffset, buffer, index + num, count - num);
2521 num += num2;
2523 if (num == count)
2524 {
2525 char ch = buffer[index + count - 1];
2527 {
2528 num--;
2530 if (num == 0)
2531 {
2533 }
2534 }
2535 return num;
2536 }
2537 if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue)
2538 {
2539 _curNode.SetValue(string.Empty);
2540 bool flag = false;
2541 int startPos = 0;
2542 int endPos = 0;
2543 while (num < count && !flag)
2544 {
2545 int outOrChars = 0;
2546 flag = ParseText(out startPos, out endPos, ref outOrChars);
2547 int num3 = count - num;
2548 if (num3 > endPos - startPos)
2549 {
2550 num3 = endPos - startPos;
2551 }
2553 num += num3;
2554 startPos += num3;
2555 }
2557 if (num == count)
2558 {
2559 char ch2 = buffer[index + count - 1];
2561 {
2562 num--;
2563 startPos--;
2564 if (num == 0)
2565 {
2567 }
2568 }
2569 }
2570 _readValueOffset = 0;
2572 }
2573 return num;
2574 }
2575
2576 public bool HasLineInfo()
2577 {
2578 return true;
2579 }
2580
2585
2587 {
2588 return LookupNamespace(prefix);
2589 }
2590
2595
2600
2601 internal string LookupPrefix(string namespaceName)
2602 {
2604 }
2605
2606 internal void ResetState()
2607 {
2608 if (_fragment)
2609 {
2611 }
2612 if (_readState != 0)
2613 {
2615 while (_namespaceManager.PopScope())
2616 {
2617 }
2618 while (InEntity)
2619 {
2621 }
2622 _readState = ReadState.Initial;
2623 _parsingFunction = ParsingFunction.SwitchToInteractiveXmlDecl;
2624 _nextParsingFunction = ParsingFunction.DocumentContent;
2625 _curNode = _nodes[0];
2627 _curNode.SetLineInfo(0, 0);
2628 _index = 0;
2629 _rootElementParsed = false;
2632 _afterResetState = true;
2633 }
2634 }
2635
2637 {
2638 switch (_parsingFunction)
2639 {
2640 case ParsingFunction.Eof:
2641 case ParsingFunction.ReaderClosed:
2642 return new StringReader(string.Empty);
2643 case ParsingFunction.OpenUrl:
2644 OpenUrl();
2645 break;
2646 case ParsingFunction.InIncrementalRead:
2647 if (!InEntity)
2648 {
2650 }
2651 break;
2652 }
2653 while (InEntity)
2654 {
2656 }
2657 _ps.appendMode = false;
2658 do
2659 {
2662 }
2663 while (ReadData() != 0);
2664 OnEof();
2665 string s = _stringBuilder.ToString();
2667 return new StringReader(s);
2668 }
2669
2670 internal int ReadChars(char[] buffer, int index, int count)
2671 {
2672 if (_parsingFunction == ParsingFunction.InIncrementalRead)
2673 {
2675 {
2676 if (_readCharsDecoder == null)
2677 {
2679 }
2682 }
2684 }
2685 if (_curNode.type != XmlNodeType.Element)
2686 {
2687 return 0;
2688 }
2690 {
2692 return 0;
2693 }
2694 if (_readCharsDecoder == null)
2695 {
2697 }
2700 }
2701
2702 internal int ReadBase64(byte[] array, int offset, int len)
2703 {
2704 if (_parsingFunction == ParsingFunction.InIncrementalRead)
2705 {
2707 {
2709 }
2710 return IncrementalRead(array, offset, len);
2711 }
2712 if (_curNode.type != XmlNodeType.Element)
2713 {
2714 return 0;
2715 }
2717 {
2719 return 0;
2720 }
2721 if (_base64Decoder == null)
2722 {
2724 }
2726 return IncrementalRead(array, offset, len);
2727 }
2728
2729 internal int ReadBinHex(byte[] array, int offset, int len)
2730 {
2731 if (_parsingFunction == ParsingFunction.InIncrementalRead)
2732 {
2734 {
2736 }
2737 return IncrementalRead(array, offset, len);
2738 }
2739 if (_curNode.type != XmlNodeType.Element)
2740 {
2741 return 0;
2742 }
2744 {
2746 return 0;
2747 }
2748 if (_binHexDecoder == null)
2749 {
2751 }
2753 return IncrementalRead(array, offset, len);
2754 }
2755
2756 internal void DtdParserProxy_OnNewLine(int pos)
2757 {
2758 OnNewLine(pos);
2759 }
2760
2762 {
2763 return ReadData();
2764 }
2765
2771
2776
2778 {
2779 if (sb == null)
2780 {
2782 _parsingMode = ParsingMode.SkipNode;
2783 ParsePI(null);
2785 }
2786 else
2787 {
2788 ParsePI(sb);
2789 }
2790 }
2791
2793 {
2794 try
2795 {
2796 if (sb == null)
2797 {
2799 _parsingMode = ParsingMode.SkipNode;
2802 }
2803 else
2804 {
2805 NodeData curNode = _curNode;
2808 _curNode.CopyTo(0, sb);
2809 _curNode = curNode;
2810 }
2811 }
2812 catch (XmlException ex)
2813 {
2814 if (ex.ResString == System.SR.Xml_UnexpectedEOF && _ps.entity != null)
2815 {
2817 return;
2818 }
2819 throw;
2820 }
2821 }
2822
2824 {
2825 if (_xmlResolver != null)
2826 {
2827 return _xmlResolver;
2828 }
2829 return new XmlUrlResolver();
2830 }
2831
2832 internal bool DtdParserProxy_PushEntity(IDtdEntityInfo entity, out int entityId)
2833 {
2834 bool result;
2835 if (entity.IsExternal)
2836 {
2837 if (IsResolverNull)
2838 {
2839 entityId = -1;
2840 return false;
2841 }
2842 result = PushExternalEntity(entity);
2843 }
2844 else
2845 {
2846 PushInternalEntity(entity);
2847 result = true;
2848 }
2849 entityId = _ps.entityId;
2850 return result;
2851 }
2852
2854 {
2855 if (_parsingStatesStackTop == -1)
2856 {
2857 oldEntity = null;
2858 newEntityId = -1;
2859 return false;
2860 }
2862 PopEntity();
2864 return true;
2865 }
2866
2867 internal bool DtdParserProxy_PushExternalSubset(string systemId, string publicId)
2868 {
2869 if (IsResolverNull)
2870 {
2871 return false;
2872 }
2873 if (_ps.baseUri == null && !string.IsNullOrEmpty(_ps.baseUriStr))
2874 {
2876 }
2877 PushExternalEntityOrSubset(publicId, systemId, _ps.baseUri, null);
2878 _ps.entity = null;
2879 _ps.entityId = 0;
2880 int charPos = _ps.charPos;
2881 if (_v1Compat)
2882 {
2883 EatWhitespaces(null);
2884 }
2885 if (!ParseXmlDeclaration(isTextDecl: true))
2886 {
2887 _ps.charPos = charPos;
2888 }
2889 return true;
2890 }
2891
2892 internal void DtdParserProxy_PushInternalDtd(string baseUri, string internalDtd)
2893 {
2897 _ps.entity = null;
2898 _ps.entityId = 0;
2899 _ps.eolNormalized = false;
2900 }
2901
2904 {
2905 Throw(e);
2906 }
2907
2915
2923
2925 private void Throw(int pos, string res, string arg)
2926 {
2927 _ps.charPos = pos;
2928 Throw(res, arg);
2929 }
2930
2932 private void Throw(int pos, string res, string[] args)
2933 {
2934 _ps.charPos = pos;
2935 Throw(res, args);
2936 }
2937
2939 private void Throw(int pos, string res)
2940 {
2941 _ps.charPos = pos;
2942 Throw(res, string.Empty);
2943 }
2944
2946 private void Throw(string res)
2947 {
2948 Throw(res, string.Empty);
2949 }
2950
2952 private void Throw(string res, int lineNo, int linePos)
2953 {
2954 Throw(new XmlException(res, string.Empty, lineNo, linePos, _ps.baseUriStr));
2955 }
2956
2958 private void Throw(string res, string arg)
2959 {
2961 }
2962
2964 private void Throw(string res, string arg, int lineNo, int linePos)
2965 {
2966 Throw(new XmlException(res, arg, lineNo, linePos, _ps.baseUriStr));
2967 }
2968
2970 private void Throw(string res, string[] args)
2971 {
2973 }
2974
2976 private void Throw(string res, string arg, Exception innerException)
2977 {
2978 Throw(res, new string[1] { arg }, innerException);
2979 }
2980
2982 private void Throw(string res, string[] args, Exception innerException)
2983 {
2985 }
2986
2988 private void Throw(Exception e)
2989 {
2990 SetErrorState();
2991 if (e is XmlException ex)
2992 {
2993 _curNode.SetLineInfo(ex.LineNumber, ex.LinePosition);
2994 }
2995 throw e;
2996 }
2997
2999 private void ReThrow(Exception e, int lineNo, int linePos)
3000 {
3001 Throw(new XmlException(e.Message, (Exception)null, lineNo, linePos, _ps.baseUriStr));
3002 }
3003
3005 private void ThrowWithoutLineInfo(string res)
3006 {
3007 Throw(new XmlException(res, string.Empty, _ps.baseUriStr));
3008 }
3009
3011 private void ThrowWithoutLineInfo(string res, string arg)
3012 {
3014 }
3015
3017 private void ThrowWithoutLineInfo(string res, string[] args, Exception innerException)
3018 {
3020 }
3021
3027
3028 private void SetErrorState()
3029 {
3031 _readState = ReadState.Error;
3032 }
3033
3034 private void SendValidationEvent(XmlSeverityType severity, string code, string arg, int lineNo, int linePos)
3035 {
3037 }
3038
3046
3048 {
3049 if (_parsingFunction == ParsingFunction.InReadValueChunk)
3050 {
3052 }
3053 else if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
3054 {
3056 }
3057 if (_parsingFunction == ParsingFunction.InReadAttributeValue)
3058 {
3060 {
3062 }
3065 _nextParsingFunction = ((_index <= 0) ? ParsingFunction.DocumentContent : ParsingFunction.ElementContent);
3066 }
3067 }
3068
3069 private void InitStreamInput(Stream stream, Encoding encoding)
3070 {
3071 InitStreamInput(null, string.Empty, stream, null, 0, encoding);
3072 }
3073
3074 private void InitStreamInput(string baseUriStr, Stream stream, Encoding encoding)
3075 {
3076 InitStreamInput(null, baseUriStr, stream, null, 0, encoding);
3077 }
3078
3079 private void InitStreamInput(Uri baseUri, Stream stream, Encoding encoding)
3080 {
3081 InitStreamInput(baseUri, baseUri.ToString(), stream, null, 0, encoding);
3082 }
3083
3084 private void InitStreamInput(Uri baseUri, string baseUriStr, Stream stream, Encoding encoding)
3085 {
3086 InitStreamInput(baseUri, baseUriStr, stream, null, 0, encoding);
3087 }
3088
3089 private void InitStreamInput(Uri baseUri, string baseUriStr, Stream stream, byte[] bytes, int byteCount, Encoding encoding)
3090 {
3092 _ps.baseUri = baseUri;
3093 _ps.baseUriStr = baseUriStr;
3094 int num;
3095 if (bytes != null)
3096 {
3097 _ps.bytes = bytes;
3099 num = _ps.bytes.Length;
3100 }
3101 else
3102 {
3103 num = ((_laterInitParam == null || !_laterInitParam.useAsync) ? XmlReader.CalcBufferSize(stream) : 65536);
3104 if (_ps.bytes == null || _ps.bytes.Length < num)
3105 {
3106 _ps.bytes = new byte[num];
3107 }
3108 }
3109 if (_ps.chars == null || _ps.chars.Length < num + 1)
3110 {
3111 _ps.chars = new char[num + 1];
3112 }
3113 _ps.bytePos = 0;
3114 while (_ps.bytesUsed < 4 && _ps.bytes.Length - _ps.bytesUsed > 0)
3115 {
3116 int num2 = stream.Read(_ps.bytes, _ps.bytesUsed, _ps.bytes.Length - _ps.bytesUsed);
3117 if (num2 == 0)
3118 {
3119 _ps.isStreamEof = true;
3120 break;
3121 }
3123 }
3124 if (encoding == null)
3125 {
3126 encoding = DetectEncoding();
3127 }
3128 SetupEncoding(encoding);
3129 EatPreamble();
3132 _ps.appendMode = true;
3133 ReadData();
3134 }
3135
3136 private void InitTextReaderInput(string baseUriStr, TextReader input)
3137 {
3138 InitTextReaderInput(baseUriStr, null, input);
3139 }
3140
3141 private void InitTextReaderInput(string baseUriStr, Uri baseUri, TextReader input)
3142 {
3144 _ps.baseUriStr = baseUriStr;
3145 _ps.baseUri = baseUri;
3146 if (_ps.chars == null)
3147 {
3149 {
3150 _ps.chars = new char[65537];
3151 }
3152 else
3153 {
3154 _ps.chars = new char[4097];
3155 }
3156 }
3159 _ps.appendMode = true;
3160 ReadData();
3161 }
3162
3163 private void InitStringInput(string baseUriStr, Encoding originalEncoding, string str)
3164 {
3165 _ps.baseUriStr = baseUriStr;
3166 _ps.baseUri = null;
3167 int length = str.Length;
3168 _ps.chars = new char[length + 1];
3169 str.CopyTo(0, _ps.chars, 0, str.Length);
3171 _ps.chars[length] = '\0';
3174 _ps.isEof = true;
3175 }
3176
3178 {
3180 if (parserContext != null)
3181 {
3182 if (parserContext.NamespaceManager != null)
3183 {
3184 _namespaceManager = parserContext.NamespaceManager;
3186 }
3187 else
3188 {
3190 }
3191 _ps.baseUriStr = parserContext.BaseURI;
3192 _ps.baseUri = null;
3195 }
3196 else
3197 {
3199 _ps.baseUriStr = string.Empty;
3200 _ps.baseUri = null;
3201 }
3203 if (fragmentType <= XmlNodeType.Attribute)
3204 {
3205 if (fragmentType != XmlNodeType.Element)
3206 {
3207 if (fragmentType != XmlNodeType.Attribute)
3208 {
3209 goto IL_012e;
3210 }
3211 _ps.appendMode = false;
3212 _parsingFunction = ParsingFunction.SwitchToInteractive;
3213 _nextParsingFunction = ParsingFunction.FragmentAttribute;
3214 }
3215 else
3216 {
3217 _nextParsingFunction = ParsingFunction.DocumentContent;
3218 }
3219 }
3220 else if (fragmentType != XmlNodeType.Document)
3221 {
3222 if (fragmentType != XmlNodeType.XmlDeclaration || !allowXmlDeclFragment)
3223 {
3224 goto IL_012e;
3225 }
3226 _ps.appendMode = false;
3227 _parsingFunction = ParsingFunction.SwitchToInteractive;
3228 _nextParsingFunction = ParsingFunction.XmlDeclarationFragment;
3229 }
3231 _fragment = true;
3232 return;
3233 IL_012e:
3235 }
3236
3238 {
3239 switch (_dtdProcessing)
3240 {
3241 case DtdProcessing.Prohibit:
3243 break;
3244 case DtdProcessing.Parse:
3246 break;
3247 case DtdProcessing.Ignore:
3248 break;
3249 }
3250 }
3251
3252 private void OpenUrl()
3253 {
3255 if (_ps.baseUri == null)
3256 {
3257 _ps.baseUri = tempResolver.ResolveUri(null, _url);
3259 }
3260 try
3261 {
3262 _ps.stream = (Stream)tempResolver.GetEntity(_ps.baseUri, null, typeof(Stream));
3263 }
3264 catch
3265 {
3266 SetErrorState();
3267 throw;
3268 }
3269 if (_ps.stream == null)
3270 {
3272 }
3275 }
3276
3278 {
3279 if (_ps.bytesUsed < 2)
3280 {
3281 return null;
3282 }
3283 int num = (_ps.bytes[0] << 8) | _ps.bytes[1];
3284 int num2 = ((_ps.bytesUsed >= 4) ? ((_ps.bytes[2] << 8) | _ps.bytes[3]) : 0);
3285 switch (num)
3286 {
3287 case 0:
3288 switch (num2)
3289 {
3290 case 65279:
3292 case 60:
3294 case 65534:
3295 return Ucs4Encoding.UCS4_2143;
3296 case 15360:
3297 return Ucs4Encoding.UCS4_2143;
3298 }
3299 break;
3300 case 65279:
3301 if (num2 == 0)
3302 {
3303 return Ucs4Encoding.UCS4_3412;
3304 }
3306 case 65534:
3307 if (num2 == 0)
3308 {
3310 }
3311 return Encoding.Unicode;
3312 case 15360:
3313 if (num2 == 0)
3314 {
3316 }
3317 return Encoding.Unicode;
3318 case 60:
3319 if (num2 == 0)
3320 {
3321 return Ucs4Encoding.UCS4_3412;
3322 }
3324 case 19567:
3325 if (num2 == 42900)
3326 {
3328 }
3329 break;
3330 case 61371:
3331 if ((num2 & 0xFF00) == 48896)
3332 {
3334 }
3335 break;
3336 }
3337 return null;
3338 }
3339
3340 private void SetupEncoding(Encoding encoding)
3341 {
3342 if (encoding == null)
3343 {
3346 return;
3347 }
3348 _ps.encoding = encoding;
3349 _ = _ps;
3350 string webName = _ps.encoding.WebName;
3351 Decoder decoder = ((webName == "utf-16") ? new UTF16Decoder(bigEndian: false) : ((!(webName == "utf-16BE")) ? encoding.GetDecoder() : new UTF16Decoder(bigEndian: true)));
3352 _ps.decoder = decoder;
3353 }
3354
3355 private void EatPreamble()
3356 {
3358 int length = preamble.Length;
3359 int i;
3360 for (i = 0; i < length && i < _ps.bytesUsed && _ps.bytes[i] == preamble[i]; i++)
3361 {
3362 }
3363 if (i == length)
3364 {
3366 }
3367 }
3368
3370 {
3372 {
3373 UnDecodeChars();
3374 _ps.appendMode = false;
3376 ReadData();
3377 }
3378 }
3379
3381 {
3382 if (_ps.stream == null)
3383 {
3384 return _ps.encoding;
3385 }
3386 if (string.Equals(newEncodingName, "ucs-2", StringComparison.OrdinalIgnoreCase) || string.Equals(newEncodingName, "utf-16", StringComparison.OrdinalIgnoreCase) || string.Equals(newEncodingName, "iso-10646-ucs-2", StringComparison.OrdinalIgnoreCase) || string.Equals(newEncodingName, "ucs-4", StringComparison.OrdinalIgnoreCase))
3387 {
3388 if (_ps.encoding.WebName != "utf-16BE" && _ps.encoding.WebName != "utf-16" && !string.Equals(newEncodingName, "ucs-4", StringComparison.OrdinalIgnoreCase))
3389 {
3390 if (_afterResetState)
3391 {
3393 }
3394 else
3395 {
3397 }
3398 }
3399 return _ps.encoding;
3400 }
3401 Encoding encoding = null;
3402 if (string.Equals(newEncodingName, "utf-8", StringComparison.OrdinalIgnoreCase))
3403 {
3404 encoding = UTF8BomThrowing;
3405 }
3406 else
3407 {
3408 try
3409 {
3411 }
3413 {
3415 }
3417 {
3419 }
3420 }
3421 if (_afterResetState && _ps.encoding.WebName != encoding.WebName)
3422 {
3424 }
3425 return encoding;
3426 }
3427
3428 private void UnDecodeChars()
3429 {
3431 {
3433 }
3435 {
3437 }
3439 if (_ps.charPos > 0)
3440 {
3442 }
3444 _ps.isEof = false;
3445 }
3446
3448 {
3450 }
3451
3452 private int ReadData()
3453 {
3454 if (_ps.isEof)
3455 {
3456 return 0;
3457 }
3458 int num;
3459 if (_ps.appendMode)
3460 {
3461 if (_ps.charsUsed == _ps.chars.Length - 1)
3462 {
3463 for (int i = 0; i < _attrCount; i++)
3464 {
3466 }
3467 char[] array = new char[_ps.chars.Length * 2];
3468 BlockCopyChars(_ps.chars, 0, array, 0, _ps.chars.Length);
3469 _ps.chars = array;
3470 }
3471 if (_ps.stream != null && _ps.bytesUsed - _ps.bytePos < 6 && _ps.bytes.Length - _ps.bytesUsed < 6)
3472 {
3473 byte[] array2 = new byte[_ps.bytes.Length * 2];
3475 _ps.bytes = array2;
3476 }
3477 num = _ps.chars.Length - _ps.charsUsed - 1;
3478 if (num > 80)
3479 {
3480 num = 80;
3481 }
3482 }
3483 else
3484 {
3485 int num2 = _ps.chars.Length;
3486 if (num2 - _ps.charsUsed <= num2 / 2)
3487 {
3488 for (int j = 0; j < _attrCount; j++)
3489 {
3491 }
3492 int num3 = _ps.charsUsed - _ps.charPos;
3493 if (num3 < num2 - 1)
3494 {
3496 if (num3 > 0)
3497 {
3499 }
3500 _ps.charPos = 0;
3502 }
3503 else
3504 {
3505 char[] array3 = new char[_ps.chars.Length * 2];
3506 BlockCopyChars(_ps.chars, 0, array3, 0, _ps.chars.Length);
3507 _ps.chars = array3;
3508 }
3509 }
3510 if (_ps.stream != null)
3511 {
3512 int num4 = _ps.bytesUsed - _ps.bytePos;
3513 if (num4 <= 128)
3514 {
3515 if (num4 == 0)
3516 {
3517 _ps.bytesUsed = 0;
3518 }
3519 else
3520 {
3523 }
3524 _ps.bytePos = 0;
3525 }
3526 }
3527 num = _ps.chars.Length - _ps.charsUsed - 1;
3528 }
3529 if (_ps.stream != null)
3530 {
3531 if (!_ps.isStreamEof && _ps.bytePos == _ps.bytesUsed && _ps.bytes.Length - _ps.bytesUsed > 0)
3532 {
3534 if (num5 == 0)
3535 {
3536 _ps.isStreamEof = true;
3537 }
3539 }
3540 int bytePos = _ps.bytePos;
3541 num = GetChars(num);
3542 if (num == 0 && _ps.bytePos != bytePos)
3543 {
3544 return ReadData();
3545 }
3546 }
3547 else if (_ps.textReader != null)
3548 {
3549 num = _ps.textReader.Read(_ps.chars, _ps.charsUsed, _ps.chars.Length - _ps.charsUsed - 1);
3550 _ps.charsUsed += num;
3551 }
3552 else
3553 {
3554 num = 0;
3555 }
3557 if (num == 0)
3558 {
3559 _ps.isEof = true;
3560 }
3561 _ps.chars[_ps.charsUsed] = '\0';
3562 return num;
3563 }
3564
3565 private int GetChars(int maxCharsCount)
3566 {
3567 int bytesUsed = _ps.bytesUsed - _ps.bytePos;
3568 if (bytesUsed == 0)
3569 {
3570 return 0;
3571 }
3572 int charsUsed;
3573 try
3574 {
3575 _ps.decoder.Convert(_ps.bytes, _ps.bytePos, bytesUsed, _ps.chars, _ps.charsUsed, maxCharsCount, flush: false, out bytesUsed, out charsUsed, out var _);
3576 }
3577 catch (ArgumentException)
3578 {
3579 InvalidCharRecovery(ref bytesUsed, out charsUsed);
3580 }
3581 _ps.bytePos += bytesUsed;
3582 _ps.charsUsed += charsUsed;
3583 return charsUsed;
3584 }
3585
3587 {
3588 int num = 0;
3589 int i = 0;
3590 try
3591 {
3592 int bytesUsed;
3593 for (; i < bytesCount; i += bytesUsed)
3594 {
3595 _ps.decoder.Convert(_ps.bytes, _ps.bytePos + i, 1, _ps.chars, _ps.charsUsed + num, 2, flush: false, out bytesUsed, out var charsUsed, out var _);
3596 num += charsUsed;
3597 }
3598 }
3599 catch (ArgumentException)
3600 {
3601 }
3602 if (num == 0)
3603 {
3605 }
3606 charsCount = num;
3607 bytesCount = i;
3608 }
3609
3610 internal void Close(bool closeInput)
3611 {
3612 if (_parsingFunction != ParsingFunction.ReaderClosed)
3613 {
3614 while (InEntity)
3615 {
3617 }
3620 _parsingFunction = ParsingFunction.ReaderClosed;
3621 _reportedEncoding = null;
3622 _reportedBaseUri = string.Empty;
3623 _readState = ReadState.Closed;
3624 _fullAttrCleanup = false;
3626 _laterInitParam = null;
3627 }
3628 }
3629
3630 private void ShiftBuffer(int sourcePos, int destPos, int count)
3631 {
3633 }
3634
3636 {
3637 do
3638 {
3639 if (_ps.charsUsed - _ps.charPos < 6)
3640 {
3641 continue;
3642 }
3644 {
3645 break;
3646 }
3647 if (!isTextDecl)
3648 {
3650 _curNode.SetNamedNode(XmlNodeType.XmlDeclaration, _xml);
3651 }
3652 _ps.charPos += 5;
3654 int num = 0;
3655 Encoding encoding = null;
3656 while (true)
3657 {
3658 int length = stringBuilder.Length;
3659 int num2 = EatWhitespaces((num == 0) ? null : stringBuilder);
3660 if (_ps.chars[_ps.charPos] == '?')
3661 {
3663 if (_ps.chars[_ps.charPos + 1] == '>')
3664 {
3665 break;
3666 }
3667 if (_ps.charPos + 1 == _ps.charsUsed)
3668 {
3669 goto IL_07a5;
3670 }
3671 ThrowUnexpectedToken("'>'");
3672 }
3673 if (num2 == 0 && num != 0)
3674 {
3676 }
3677 int num3 = ParseName();
3678 NodeData nodeData = null;
3679 char c = _ps.chars[_ps.charPos];
3680 if (c != 'e')
3681 {
3682 if (c != 's')
3683 {
3684 if (c != 'v' || !XmlConvert.StrEqual(_ps.chars, _ps.charPos, num3 - _ps.charPos, "version") || num != 0)
3685 {
3686 goto IL_03af;
3687 }
3688 if (!isTextDecl)
3689 {
3690 nodeData = AddAttributeNoChecks("version", 1);
3691 }
3692 }
3693 else
3694 {
3695 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, num3 - _ps.charPos, "standalone") || (num != 1 && num != 2) || isTextDecl)
3696 {
3697 goto IL_03af;
3698 }
3699 if (!isTextDecl)
3700 {
3701 nodeData = AddAttributeNoChecks("standalone", 1);
3702 }
3703 num = 2;
3704 }
3705 }
3706 else
3707 {
3708 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, num3 - _ps.charPos, "encoding") || (num != 1 && (!isTextDecl || num != 0)))
3709 {
3710 goto IL_03af;
3711 }
3712 if (!isTextDecl)
3713 {
3714 nodeData = AddAttributeNoChecks("encoding", 1);
3715 }
3716 num = 1;
3717 }
3718 goto IL_03c4;
3719 IL_03c4:
3720 if (!isTextDecl)
3721 {
3722 nodeData.SetLineInfo(_ps.LineNo, _ps.LinePos);
3723 }
3725 _ps.charPos = num3;
3726 if (_ps.chars[_ps.charPos] != '=')
3727 {
3729 if (_ps.chars[_ps.charPos] != '=')
3730 {
3732 }
3733 }
3734 stringBuilder.Append('=');
3735 _ps.charPos++;
3736 char c2 = _ps.chars[_ps.charPos];
3737 if (c2 != '"' && c2 != '\'')
3738 {
3740 c2 = _ps.chars[_ps.charPos];
3741 if (c2 != '"' && c2 != '\'')
3742 {
3743 ThrowUnexpectedToken("\"", "'");
3744 }
3745 }
3746 stringBuilder.Append(c2);
3747 _ps.charPos++;
3748 if (!isTextDecl)
3749 {
3751 nodeData.SetLineInfo2(_ps.LineNo, _ps.LinePos);
3752 }
3753 int i = _ps.charPos;
3754 char[] chars;
3755 while (true)
3756 {
3758 {
3759 }
3760 if (_ps.chars[i] == c2)
3761 {
3762 break;
3763 }
3764 if (i == _ps.charsUsed)
3765 {
3766 if (ReadData() != 0)
3767 {
3768 continue;
3769 }
3770 goto IL_0783;
3771 }
3772 goto IL_0790;
3773 }
3774 switch (num)
3775 {
3776 case 0:
3777 if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, i - _ps.charPos, "1.0"))
3778 {
3779 if (!isTextDecl)
3780 {
3781 nodeData.SetValue(_ps.chars, _ps.charPos, i - _ps.charPos);
3782 }
3783 num = 1;
3784 }
3785 else
3786 {
3787 string arg = new string(_ps.chars, _ps.charPos, i - _ps.charPos);
3789 }
3790 break;
3791 case 1:
3792 {
3793 string text = new string(_ps.chars, _ps.charPos, i - _ps.charPos);
3794 encoding = CheckEncoding(text);
3795 if (!isTextDecl)
3796 {
3797 nodeData.SetValue(text);
3798 }
3799 num = 2;
3800 break;
3801 }
3802 case 2:
3803 if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, i - _ps.charPos, "yes"))
3804 {
3805 _standalone = true;
3806 }
3807 else if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, i - _ps.charPos, "no"))
3808 {
3809 _standalone = false;
3810 }
3811 else
3812 {
3814 }
3815 if (!isTextDecl)
3816 {
3817 nodeData.SetValue(_ps.chars, _ps.charPos, i - _ps.charPos);
3818 }
3819 num = 3;
3820 break;
3821 }
3822 stringBuilder.Append(chars, _ps.charPos, i - _ps.charPos);
3823 stringBuilder.Append(c2);
3824 _ps.charPos = i + 1;
3825 continue;
3826 IL_07a5:
3827 if (_ps.isEof || ReadData() == 0)
3828 {
3830 }
3831 continue;
3832 IL_0790:
3834 goto IL_07a5;
3835 IL_0783:
3837 goto IL_07a5;
3838 IL_03af:
3840 goto IL_03c4;
3841 }
3842 if (num == 0)
3843 {
3845 }
3846 _ps.charPos += 2;
3847 if (!isTextDecl)
3848 {
3849 _curNode.SetValue(stringBuilder.ToString());
3852 _parsingFunction = ParsingFunction.ResetAttributesRootLevel;
3853 }
3854 if (encoding == null)
3855 {
3856 if (isTextDecl)
3857 {
3859 }
3860 if (_afterResetState)
3861 {
3862 string webName = _ps.encoding.WebName;
3863 if (webName != "utf-8" && webName != "utf-16" && webName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding))
3864 {
3865 Throw(System.SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
3866 }
3867 }
3869 {
3871 }
3872 }
3873 else
3874 {
3875 SwitchEncoding(encoding);
3876 }
3877 _ps.appendMode = false;
3878 return true;
3879 }
3880 while (ReadData() != 0);
3881 if (!isTextDecl)
3882 {
3884 }
3885 if (_afterResetState)
3886 {
3887 string webName2 = _ps.encoding.WebName;
3888 if (webName2 != "utf-8" && webName2 != "utf-16" && webName2 != "utf-16BE" && !(_ps.encoding is Ucs4Encoding))
3889 {
3890 Throw(System.SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
3891 }
3892 }
3894 {
3896 }
3897 _ps.appendMode = false;
3898 return false;
3899 }
3900
3902 {
3903 bool flag = false;
3904 while (true)
3905 {
3906 bool flag2 = false;
3907 int charPos = _ps.charPos;
3908 char[] chars = _ps.chars;
3909 if (chars[charPos] == '<')
3910 {
3911 flag2 = true;
3912 if (_ps.charsUsed - charPos >= 4)
3913 {
3914 charPos++;
3915 switch (chars[charPos])
3916 {
3917 case '?':
3918 _ps.charPos = charPos + 1;
3919 if (!ParsePI())
3920 {
3921 continue;
3922 }
3923 return true;
3924 case '!':
3925 charPos++;
3926 if (_ps.charsUsed - charPos < 2)
3927 {
3928 break;
3929 }
3930 if (chars[charPos] == '-')
3931 {
3932 if (chars[charPos + 1] == '-')
3933 {
3934 _ps.charPos = charPos + 2;
3935 if (!ParseComment())
3936 {
3937 continue;
3938 }
3939 return true;
3940 }
3941 ThrowUnexpectedToken(charPos + 1, "-");
3942 break;
3943 }
3944 if (chars[charPos] == '[')
3945 {
3946 if (_fragmentType != XmlNodeType.Document)
3947 {
3948 charPos++;
3949 if (_ps.charsUsed - charPos < 6)
3950 {
3951 break;
3952 }
3953 if (XmlConvert.StrEqual(chars, charPos, 6, "CDATA["))
3954 {
3955 _ps.charPos = charPos + 6;
3956 ParseCData();
3957 if (_fragmentType == XmlNodeType.None)
3958 {
3959 _fragmentType = XmlNodeType.Element;
3960 }
3961 return true;
3962 }
3963 ThrowUnexpectedToken(charPos, "CDATA[");
3964 }
3965 else
3966 {
3968 }
3969 break;
3970 }
3971 if (_fragmentType == XmlNodeType.Document || _fragmentType == XmlNodeType.None)
3972 {
3973 _fragmentType = XmlNodeType.Document;
3974 _ps.charPos = charPos;
3975 if (!ParseDoctypeDecl())
3976 {
3977 continue;
3978 }
3979 return true;
3980 }
3981 if (ParseUnexpectedToken(charPos) == "DOCTYPE")
3982 {
3984 }
3985 else
3986 {
3987 ThrowUnexpectedToken(charPos, "<!--", "<[CDATA[");
3988 }
3989 break;
3990 case '/':
3991 Throw(charPos + 1, System.SR.Xml_UnexpectedEndTag);
3992 break;
3993 default:
3995 {
3996 if (_fragmentType == XmlNodeType.Document)
3997 {
3998 Throw(charPos, System.SR.Xml_MultipleRoots);
3999 }
4000 if (_fragmentType == XmlNodeType.None)
4001 {
4002 _fragmentType = XmlNodeType.Element;
4003 }
4004 }
4005 _ps.charPos = charPos;
4006 _rootElementParsed = true;
4007 ParseElement();
4008 return true;
4009 }
4010 }
4011 }
4012 else if (chars[charPos] == '&')
4013 {
4014 if (_fragmentType != XmlNodeType.Document)
4015 {
4016 if (_fragmentType == XmlNodeType.None)
4017 {
4018 _fragmentType = XmlNodeType.Element;
4019 }
4020 int charRefEndPos;
4022 {
4023 case EntityType.Unexpanded:
4024 if (_parsingFunction == ParsingFunction.EntityReference)
4025 {
4027 }
4029 return true;
4030 case EntityType.CharacterDec:
4031 case EntityType.CharacterHex:
4032 case EntityType.CharacterNamed:
4033 if (ParseText())
4034 {
4035 return true;
4036 }
4037 break;
4038 default:
4039 chars = _ps.chars;
4040 charPos = _ps.charPos;
4041 break;
4042 }
4043 continue;
4044 }
4046 }
4047 else if (charPos != _ps.charsUsed && (!(_v1Compat || flag) || chars[charPos] != 0))
4048 {
4049 if (_fragmentType == XmlNodeType.Document)
4050 {
4052 {
4053 return true;
4054 }
4055 }
4056 else if (ParseText())
4057 {
4058 if (_fragmentType == XmlNodeType.None && _curNode.type == XmlNodeType.Text)
4059 {
4060 _fragmentType = XmlNodeType.Element;
4061 }
4062 return true;
4063 }
4064 continue;
4065 }
4066 if (ReadData() != 0)
4067 {
4068 charPos = _ps.charPos;
4069 charPos = _ps.charPos;
4070 chars = _ps.chars;
4071 continue;
4072 }
4073 if (flag2)
4074 {
4076 }
4077 if (!InEntity)
4078 {
4079 break;
4080 }
4082 {
4084 return true;
4085 }
4086 }
4087 if (!_rootElementParsed && _fragmentType == XmlNodeType.Document)
4088 {
4090 }
4091 if (_fragmentType == XmlNodeType.None)
4092 {
4093 _fragmentType = ((!_rootElementParsed) ? XmlNodeType.Element : XmlNodeType.Document);
4094 }
4095 OnEof();
4096 return false;
4097 }
4098
4099 private bool ParseElementContent()
4100 {
4101 while (true)
4102 {
4103 int charPos = _ps.charPos;
4104 char[] chars = _ps.chars;
4105 switch (chars[charPos])
4106 {
4107 case '<':
4108 switch (chars[charPos + 1])
4109 {
4110 case '?':
4111 _ps.charPos = charPos + 2;
4112 if (!ParsePI())
4113 {
4114 continue;
4115 }
4116 return true;
4117 case '!':
4118 charPos += 2;
4119 if (_ps.charsUsed - charPos < 2)
4120 {
4121 break;
4122 }
4123 if (chars[charPos] == '-')
4124 {
4125 if (chars[charPos + 1] == '-')
4126 {
4127 _ps.charPos = charPos + 2;
4128 if (!ParseComment())
4129 {
4130 continue;
4131 }
4132 return true;
4133 }
4134 ThrowUnexpectedToken(charPos + 1, "-");
4135 }
4136 else if (chars[charPos] == '[')
4137 {
4138 charPos++;
4139 if (_ps.charsUsed - charPos >= 6)
4140 {
4141 if (XmlConvert.StrEqual(chars, charPos, 6, "CDATA["))
4142 {
4143 _ps.charPos = charPos + 6;
4144 ParseCData();
4145 return true;
4146 }
4147 ThrowUnexpectedToken(charPos, "CDATA[");
4148 }
4149 }
4150 else if (ParseUnexpectedToken(charPos) == "DOCTYPE")
4151 {
4153 }
4154 else
4155 {
4156 ThrowUnexpectedToken(charPos, "<!--", "<[CDATA[");
4157 }
4158 break;
4159 case '/':
4160 _ps.charPos = charPos + 2;
4162 return true;
4163 default:
4164 if (charPos + 1 != _ps.charsUsed)
4165 {
4166 _ps.charPos = charPos + 1;
4167 ParseElement();
4168 return true;
4169 }
4170 break;
4171 }
4172 break;
4173 case '&':
4174 if (!ParseText())
4175 {
4176 continue;
4177 }
4178 return true;
4179 default:
4180 if (charPos != _ps.charsUsed)
4181 {
4182 if (!ParseText())
4183 {
4184 continue;
4185 }
4186 return true;
4187 }
4188 break;
4189 }
4190 if (ReadData() != 0)
4191 {
4192 continue;
4193 }
4194 if (_ps.charsUsed - _ps.charPos != 0)
4195 {
4197 }
4198 if (!InEntity)
4199 {
4200 if (_index == 0 && _fragmentType != XmlNodeType.Document)
4201 {
4202 OnEof();
4203 return false;
4204 }
4206 }
4208 {
4209 break;
4210 }
4211 }
4213 return true;
4214 }
4215
4217 {
4218 if (_index == 0 && _curNode.type != XmlNodeType.Element)
4219 {
4221 return;
4222 }
4223 int num = ((_parsingFunction == ParsingFunction.InIncrementalRead) ? _index : (_index - 1));
4225 while (num >= 0)
4226 {
4227 NodeData nodeData = _nodes[num];
4228 if (nodeData.type == XmlNodeType.Element)
4229 {
4230 _stringBuilder.Append(nodeData.GetNameWPrefix(_nameTable));
4231 if (num > 0)
4232 {
4233 _stringBuilder.Append(", ");
4234 }
4235 else
4236 {
4238 }
4239 }
4240 num--;
4241 }
4243 }
4244
4245 private void ParseElement()
4246 {
4247 int num = _ps.charPos;
4248 char[] chars = _ps.chars;
4249 int colonPos = -1;
4251 while (true)
4252 {
4254 {
4255 num++;
4256 while (true)
4257 {
4259 {
4260 num++;
4261 continue;
4262 }
4263 if (chars[num] != ':')
4264 {
4265 break;
4266 }
4267 if (colonPos == -1)
4268 {
4269 goto IL_0088;
4270 }
4271 if (!_supportNamespaces)
4272 {
4273 num++;
4274 continue;
4275 }
4276 goto IL_006c;
4277 }
4278 if (num + 1 < _ps.charsUsed)
4279 {
4280 break;
4281 }
4282 }
4283 goto IL_00a0;
4284 IL_0088:
4285 colonPos = num;
4286 num++;
4287 continue;
4288 IL_00a0:
4289 num = ParseQName(out colonPos);
4290 chars = _ps.chars;
4291 break;
4292 IL_006c:
4294 goto IL_00a0;
4295 }
4297 if (colonPos == -1 || !_supportNamespaces)
4298 {
4300 }
4301 else
4302 {
4303 int charPos = _ps.charPos;
4304 int num2 = colonPos - charPos;
4305 if (num2 == _lastPrefix.Length && XmlConvert.StrEqual(chars, charPos, num2, _lastPrefix))
4306 {
4308 }
4309 else
4310 {
4313 }
4314 }
4315 char c = chars[num];
4317 {
4318 _ps.charPos = num;
4320 return;
4321 }
4322 switch (c)
4323 {
4324 case '>':
4325 _ps.charPos = num + 1;
4326 _parsingFunction = ParsingFunction.MoveToElementContent;
4327 break;
4328 case '/':
4329 if (num + 1 == _ps.charsUsed)
4330 {
4331 _ps.charPos = num;
4332 if (ReadData() == 0)
4333 {
4334 Throw(num, System.SR.Xml_UnexpectedEOF, ">");
4335 }
4336 num = _ps.charPos;
4337 chars = _ps.chars;
4338 }
4339 if (chars[num + 1] == '>')
4340 {
4343 _parsingFunction = ParsingFunction.PopEmptyElementContext;
4344 _ps.charPos = num + 2;
4345 }
4346 else
4347 {
4348 ThrowUnexpectedToken(num, ">");
4349 }
4350 break;
4351 default:
4353 break;
4354 }
4356 {
4358 }
4360 }
4361
4363 {
4365 if (dtdAttributeListInfo == null)
4366 {
4367 return;
4368 }
4369 if (_normalize && dtdAttributeListInfo.HasNonCDataAttributes)
4370 {
4371 for (int i = _index + 1; i < _index + 1 + _attrCount; i++)
4372 {
4374 IDtdAttributeInfo dtdAttributeInfo = dtdAttributeListInfo.LookupAttribute(nodeData.prefix, nodeData.localName);
4375 if (dtdAttributeInfo == null || !dtdAttributeInfo.IsNonCDataType)
4376 {
4377 continue;
4378 }
4379 if (DtdValidation && _standalone && dtdAttributeInfo.IsDeclaredInExternal)
4380 {
4381 string stringValue = nodeData.StringValue;
4382 nodeData.TrimSpacesInValue();
4383 if (stringValue != nodeData.StringValue)
4384 {
4386 }
4387 }
4388 else
4389 {
4390 nodeData.TrimSpacesInValue();
4391 }
4392 }
4393 }
4394 IEnumerable<IDtdDefaultAttributeInfo> enumerable = dtdAttributeListInfo.LookupDefaultAttributes();
4395 if (enumerable == null)
4396 {
4397 return;
4398 }
4399 int attrCount = _attrCount;
4400 NodeData[] array = null;
4401 if (_attrCount >= 250)
4402 {
4403 array = new NodeData[_attrCount];
4405 object[] array2 = array;
4407 }
4408 foreach (IDtdDefaultAttributeInfo item in enumerable)
4409 {
4410 if (AddDefaultAttributeDtd(item, definedInDtd: true, array) && DtdValidation && _standalone && item.IsDeclaredInExternal)
4411 {
4412 string prefix = item.Prefix;
4413 string arg = ((prefix.Length == 0) ? item.LocalName : (prefix + ":" + item.LocalName));
4415 }
4416 }
4418 {
4421 }
4422 }
4423
4424 private void ParseEndElement()
4425 {
4427 int length = nodeData.prefix.Length;
4428 int length2 = nodeData.localName.Length;
4429 while (_ps.charsUsed - _ps.charPos < length + length2 + 1 && ReadData() != 0)
4430 {
4431 }
4432 char[] chars = _ps.chars;
4433 int num;
4434 if (nodeData.prefix.Length == 0)
4435 {
4436 if (!XmlConvert.StrEqual(chars, _ps.charPos, length2, nodeData.localName))
4437 {
4439 }
4440 num = length2;
4441 }
4442 else
4443 {
4444 int num2 = _ps.charPos + length;
4445 if (!XmlConvert.StrEqual(chars, _ps.charPos, length, nodeData.prefix) || chars[num2] != ':' || !XmlConvert.StrEqual(chars, num2 + 1, length2, nodeData.localName))
4446 {
4448 }
4449 num = length2 + length + 1;
4450 }
4451 LineInfo lineInfo = new LineInfo(_ps.lineNo, _ps.LinePos);
4452 int num3;
4453 while (true)
4454 {
4455 num3 = _ps.charPos + num;
4456 chars = _ps.chars;
4457 if (num3 != _ps.charsUsed)
4458 {
4460 {
4462 }
4463 if (chars[num3] != '>')
4464 {
4465 char c;
4466 while (XmlCharType.IsWhiteSpace(c = chars[num3]))
4467 {
4468 num3++;
4469 switch (c)
4470 {
4471 case '\n':
4472 OnNewLine(num3);
4473 break;
4474 case '\r':
4475 if (chars[num3] == '\n')
4476 {
4477 num3++;
4478 }
4479 else if (num3 == _ps.charsUsed && !_ps.isEof)
4480 {
4481 break;
4482 }
4483 OnNewLine(num3);
4484 break;
4485 }
4486 }
4487 }
4488 if (chars[num3] == '>')
4489 {
4490 break;
4491 }
4492 if (num3 != _ps.charsUsed)
4493 {
4495 }
4496 }
4497 if (ReadData() == 0)
4498 {
4500 }
4501 }
4502 _index--;
4504 nodeData.lineInfo = lineInfo;
4505 nodeData.type = XmlNodeType.EndElement;
4506 _ps.charPos = num3 + 1;
4507 _nextParsingFunction = ((_index > 0) ? _parsingFunction : ParsingFunction.DocumentContent);
4508 _parsingFunction = ParsingFunction.PopElementContext;
4509 }
4510
4512 {
4513 if (startTag.type == XmlNodeType.Element)
4514 {
4515 int colonPos;
4516 int num = ParseQName(out colonPos);
4517 Throw(args: new string[4]
4518 {
4519 startTag.GetNameWPrefix(_nameTable),
4520 startTag.lineInfo.lineNo.ToString(CultureInfo.InvariantCulture),
4521 startTag.lineInfo.linePos.ToString(CultureInfo.InvariantCulture),
4522 new string(_ps.chars, _ps.charPos, num - _ps.charPos)
4524 }
4525 else
4526 {
4528 }
4529 }
4530
4531 private void ParseAttributes()
4532 {
4533 int num = _ps.charPos;
4534 char[] chars = _ps.chars;
4535 NodeData nodeData = null;
4536 while (true)
4537 {
4538 int num2 = 0;
4539 while (true)
4540 {
4541 char c;
4542 int num3;
4543 if (XmlCharType.IsWhiteSpace(c = chars[num]))
4544 {
4545 switch (c)
4546 {
4547 case '\n':
4548 OnNewLine(num + 1);
4549 num2++;
4550 goto IL_0085;
4551 case '\r':
4552 if (chars[num + 1] == '\n')
4553 {
4554 OnNewLine(num + 2);
4555 num2++;
4556 num++;
4557 goto IL_0085;
4558 }
4559 if (num + 1 != _ps.charsUsed)
4560 {
4561 OnNewLine(num + 1);
4562 num2++;
4563 goto IL_0085;
4564 }
4565 break;
4566 default:
4567 goto IL_0085;
4568 }
4569 _ps.charPos = num;
4570 }
4571 else
4572 {
4573 num3 = 0;
4574 char c2;
4576 {
4577 num3 = 1;
4578 }
4579 if (num3 != 0)
4580 {
4581 goto IL_0171;
4582 }
4583 if (c2 == '>')
4584 {
4585 _ps.charPos = num + 1;
4586 _parsingFunction = ParsingFunction.MoveToElementContent;
4587 goto IL_0438;
4588 }
4589 if (c2 == '/')
4590 {
4591 if (num + 1 != _ps.charsUsed)
4592 {
4593 if (chars[num + 1] == '>')
4594 {
4595 _ps.charPos = num + 2;
4598 _parsingFunction = ParsingFunction.PopEmptyElementContext;
4599 goto IL_0438;
4600 }
4601 ThrowUnexpectedToken(num + 1, ">");
4602 goto IL_0171;
4603 }
4604 }
4605 else if (num != _ps.charsUsed)
4606 {
4607 if (c2 != ':' || _supportNamespaces)
4608 {
4610 }
4611 goto IL_0171;
4612 }
4613 }
4614 _ps.lineNo -= num2;
4615 if (ReadData() != 0)
4616 {
4617 num = _ps.charPos;
4618 chars = _ps.chars;
4619 }
4620 else
4621 {
4623 }
4624 break;
4625 IL_0438:
4627 {
4629 }
4632 {
4635 }
4636 if (_attrDuplWalkCount >= 250)
4637 {
4639 }
4640 return;
4641 IL_0085:
4642 num++;
4643 continue;
4644 IL_0171:
4645 if (num == _ps.charPos)
4646 {
4648 }
4649 _ps.charPos = num;
4650 int linePos = _ps.LinePos;
4651 int colonPos = -1;
4652 num += num3;
4653 while (true)
4654 {
4655 char c3;
4657 {
4658 num++;
4659 continue;
4660 }
4661 if (c3 == ':')
4662 {
4663 if (colonPos != -1)
4664 {
4666 {
4668 break;
4669 }
4670 num++;
4671 continue;
4672 }
4673 colonPos = num;
4674 num++;
4676 {
4677 num++;
4678 continue;
4679 }
4680 num = ParseQName(out colonPos);
4681 chars = _ps.chars;
4682 break;
4683 }
4684 if (num + 1 >= _ps.charsUsed)
4685 {
4686 num = ParseQName(out colonPos);
4687 chars = _ps.chars;
4688 }
4689 break;
4690 }
4692 nodeData.SetLineInfo(_ps.LineNo, linePos);
4693 if (chars[num] != '=')
4694 {
4695 _ps.charPos = num;
4696 EatWhitespaces(null);
4697 num = _ps.charPos;
4698 if (chars[num] != '=')
4699 {
4701 }
4702 }
4703 num++;
4704 char c4 = chars[num];
4705 if (c4 != '"' && c4 != '\'')
4706 {
4707 _ps.charPos = num;
4708 EatWhitespaces(null);
4709 num = _ps.charPos;
4710 c4 = chars[num];
4711 if (c4 != '"' && c4 != '\'')
4712 {
4713 ThrowUnexpectedToken("\"", "'");
4714 }
4715 }
4716 num++;
4717 _ps.charPos = num;
4719 nodeData.SetLineInfo2(_ps.LineNo, _ps.LinePos);
4720 char c5;
4722 {
4723 num++;
4724 }
4725 if (c5 == c4)
4726 {
4727 nodeData.SetValue(chars, _ps.charPos, num - _ps.charPos);
4728 num++;
4729 _ps.charPos = num;
4730 }
4731 else
4732 {
4734 num = _ps.charPos;
4735 chars = _ps.chars;
4736 }
4737 if (nodeData.prefix.Length == 0)
4738 {
4739 if (Ref.Equal(nodeData.localName, _xmlNs))
4740 {
4742 }
4743 }
4744 else if (Ref.Equal(nodeData.prefix, _xmlNs))
4745 {
4747 }
4748 else if (Ref.Equal(nodeData.prefix, _xml))
4749 {
4751 }
4752 break;
4753 }
4754 }
4755 }
4756
4758 {
4759 if (_curNode.prefix.Length == 0)
4760 {
4762 }
4763 else
4764 {
4766 }
4767 }
4768
4770 {
4771 for (int i = _index + 1; i < _index + _attrCount + 1; i++)
4772 {
4774 if (nodeData.type == XmlNodeType.Attribute && nodeData.prefix.Length > 0)
4775 {
4777 }
4778 }
4779 }
4780
4781 private void AttributeDuplCheck()
4782 {
4783 if (_attrCount < 250)
4784 {
4785 for (int i = _index + 1; i < _index + 1 + _attrCount; i++)
4786 {
4788 for (int j = i + 1; j < _index + 1 + _attrCount; j++)
4789 {
4790 if (Ref.Equal(nodeData.localName, _nodes[j].localName) && Ref.Equal(nodeData.ns, _nodes[j].ns))
4791 {
4793 }
4794 }
4795 }
4796 return;
4797 }
4799 {
4801 }
4805 for (int k = 1; k < _attrCount; k++)
4806 {
4808 if (Ref.Equal(nodeData2.localName, nodeData3.localName) && Ref.Equal(nodeData2.ns, nodeData3.ns))
4809 {
4810 Throw(System.SR.Xml_DupAttributeName, nodeData3.GetNameWPrefix(_nameTable), nodeData3.LineNo, nodeData3.LinePos);
4811 }
4813 }
4814 }
4815
4817 {
4819 {
4820 string text = _nameTable.Add(attr.StringValue);
4821 attr.ns = _nameTable.Add("http://www.w3.org/2000/xmlns/");
4823 {
4825 }
4827 AddNamespace(string.Empty, text, attr);
4828 }
4829 }
4830
4832 {
4834 {
4835 string text = _nameTable.Add(attr.StringValue);
4836 if (text.Length == 0)
4837 {
4838 Throw(System.SR.Xml_BadNamespaceDecl, attr.lineInfo2.lineNo, attr.lineInfo2.linePos - 1);
4839 }
4840 AddNamespace(attr.localName, text, attr);
4841 }
4842 }
4843
4845 {
4846 string localName = attr.localName;
4847 if (!(localName == "space"))
4848 {
4849 if (localName == "lang")
4850 {
4852 {
4854 }
4855 _xmlContext.xmlLang = attr.StringValue;
4856 }
4857 return;
4858 }
4860 {
4862 }
4863 string text = XmlConvert.TrimString(attr.StringValue);
4864 if (!(text == "preserve"))
4865 {
4866 if (text == "default")
4867 {
4869 }
4870 else
4871 {
4872 Throw(System.SR.Xml_InvalidXmlSpace, attr.StringValue, attr.lineInfo.lineNo, attr.lineInfo.linePos);
4873 }
4874 }
4875 else
4876 {
4877 _xmlContext.xmlSpace = XmlSpace.Preserve;
4878 }
4879 }
4880
4881 private void ParseAttributeValueSlow(int curPos, char quoteChar, NodeData attr)
4882 {
4883 int charRefEndPos = curPos;
4884 char[] chars = _ps.chars;
4885 int entityId = _ps.entityId;
4886 int num = 0;
4887 LineInfo lineInfo = new LineInfo(_ps.lineNo, _ps.LinePos);
4888 NodeData lastChunk = null;
4889 while (true)
4890 {
4892 {
4893 charRefEndPos++;
4894 continue;
4895 }
4896 if (charRefEndPos - _ps.charPos > 0)
4897 {
4900 }
4901 if (chars[charRefEndPos] == quoteChar && entityId == _ps.entityId)
4902 {
4903 break;
4904 }
4905 switch (chars[charRefEndPos])
4906 {
4907 case '\n':
4908 charRefEndPos++;
4910 if (_normalize)
4911 {
4913 _ps.charPos++;
4914 }
4915 continue;
4916 case '\r':
4917 if (chars[charRefEndPos + 1] == '\n')
4918 {
4919 charRefEndPos += 2;
4920 if (_normalize)
4921 {
4924 }
4925 }
4926 else
4927 {
4928 if (charRefEndPos + 1 >= _ps.charsUsed && !_ps.isEof)
4929 {
4930 break;
4931 }
4932 charRefEndPos++;
4933 if (_normalize)
4934 {
4937 }
4938 }
4940 continue;
4941 case '\t':
4942 charRefEndPos++;
4943 if (_normalize)
4944 {
4946 _ps.charPos++;
4947 }
4948 continue;
4949 case '"':
4950 case '\'':
4951 case '>':
4952 charRefEndPos++;
4953 continue;
4954 case '<':
4956 break;
4957 case '&':
4958 {
4959 if (charRefEndPos - _ps.charPos > 0)
4960 {
4962 }
4964 int entityId2 = _ps.entityId;
4965 LineInfo lineInfo2 = new LineInfo(_ps.lineNo, _ps.LinePos + 1);
4967 {
4968 case EntityType.Unexpanded:
4969 if (_parsingMode == ParsingMode.Full && _ps.entityId == entityId)
4970 {
4971 int num3 = _stringBuilder.Length - num;
4972 if (num3 > 0)
4973 {
4974 NodeData nodeData3 = new NodeData();
4975 nodeData3.lineInfo = lineInfo;
4977 nodeData3.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(num, num3));
4979 }
4980 _ps.charPos++;
4981 string text = ParseEntityName();
4982 NodeData nodeData4 = new NodeData();
4983 nodeData4.lineInfo = lineInfo2;
4985 nodeData4.SetNamedNode(XmlNodeType.EntityReference, text);
4990 num = _stringBuilder.Length;
4991 lineInfo.Set(_ps.LineNo, _ps.LinePos);
4992 _fullAttrCleanup = true;
4993 }
4994 else
4995 {
4996 _ps.charPos++;
4998 }
5000 break;
5001 case EntityType.ExpandedInAttribute:
5002 if (_parsingMode == ParsingMode.Full && entityId2 == entityId)
5003 {
5004 int num2 = _stringBuilder.Length - num;
5005 if (num2 > 0)
5006 {
5007 NodeData nodeData = new NodeData();
5008 nodeData.lineInfo = lineInfo;
5010 nodeData.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(num, num2));
5012 }
5013 NodeData nodeData2 = new NodeData();
5014 nodeData2.lineInfo = lineInfo2;
5016 nodeData2.SetNamedNode(XmlNodeType.EntityReference, _ps.entity.Name);
5018 _fullAttrCleanup = true;
5019 }
5021 break;
5022 default:
5024 break;
5025 case EntityType.CharacterDec:
5026 case EntityType.CharacterHex:
5027 case EntityType.CharacterNamed:
5028 break;
5029 }
5030 chars = _ps.chars;
5031 continue;
5032 }
5033 default:
5034 {
5036 {
5037 break;
5038 }
5039 char ch = chars[charRefEndPos];
5041 {
5042 if (charRefEndPos + 1 == _ps.charsUsed)
5043 {
5044 break;
5045 }
5046 charRefEndPos++;
5048 {
5049 charRefEndPos++;
5050 continue;
5051 }
5052 }
5054 break;
5055 }
5056 }
5057 if (ReadData() == 0)
5058 {
5059 if (_ps.charsUsed - _ps.charPos > 0)
5060 {
5061 if (_ps.chars[_ps.charPos] != '\r')
5062 {
5064 }
5065 }
5066 else
5067 {
5068 if (!InEntity)
5069 {
5070 if (_fragmentType == XmlNodeType.Attribute)
5071 {
5072 if (entityId != _ps.entityId)
5073 {
5075 }
5076 break;
5077 }
5079 }
5081 {
5083 }
5084 if (entityId == _ps.entityId)
5085 {
5086 num = _stringBuilder.Length;
5087 lineInfo.Set(_ps.LineNo, _ps.LinePos);
5088 }
5089 }
5090 }
5092 chars = _ps.chars;
5093 }
5094 if (attr.nextAttrValueChunk != null)
5095 {
5096 int num4 = _stringBuilder.Length - num;
5097 if (num4 > 0)
5098 {
5099 NodeData nodeData5 = new NodeData();
5100 nodeData5.lineInfo = lineInfo;
5102 nodeData5.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(num, num4));
5104 }
5105 }
5107 attr.SetValue(_stringBuilder.ToString());
5109 }
5110
5112 {
5113 if (lastChunk == null)
5114 {
5115 lastChunk = chunk;
5117 }
5118 else
5119 {
5121 lastChunk = chunk;
5122 }
5123 }
5124
5125 private bool ParseText()
5126 {
5127 int outOrChars = 0;
5128 int startPos;
5129 int endPos;
5130 if (_parsingMode != 0)
5131 {
5132 while (!ParseText(out startPos, out endPos, ref outOrChars))
5133 {
5134 }
5135 }
5136 else
5137 {
5139 if (ParseText(out startPos, out endPos, ref outOrChars))
5140 {
5141 if (endPos - startPos != 0)
5142 {
5144 if (textNodeType != 0)
5145 {
5147 return true;
5148 }
5149 }
5150 }
5151 else if (_v1Compat)
5152 {
5153 do
5154 {
5155 if (endPos - startPos > 0)
5156 {
5158 }
5159 }
5160 while (!ParseText(out startPos, out endPos, ref outOrChars));
5161 if (endPos - startPos > 0)
5162 {
5164 }
5166 if (textNodeType2 != 0)
5167 {
5170 return true;
5171 }
5173 }
5174 else
5175 {
5176 bool flag = false;
5177 if (outOrChars > 32)
5178 {
5181 _parsingFunction = ParsingFunction.PartialTextValue;
5182 return true;
5183 }
5184 if (endPos - startPos > 0)
5185 {
5187 }
5188 do
5189 {
5190 flag = ParseText(out startPos, out endPos, ref outOrChars);
5191 if (endPos - startPos > 0)
5192 {
5194 }
5195 }
5196 while (!flag && outOrChars <= 32 && _stringBuilder.Length < 4096);
5198 if (xmlNodeType != 0)
5199 {
5202 if (!flag)
5203 {
5205 _parsingFunction = ParsingFunction.PartialTextValue;
5206 }
5207 return true;
5208 }
5210 if (!flag)
5211 {
5212 while (!ParseText(out startPos, out endPos, ref outOrChars))
5213 {
5214 }
5215 }
5216 }
5217 }
5218 if (_parsingFunction == ParsingFunction.ReportEndEntity)
5219 {
5222 return true;
5223 }
5224 if (_parsingFunction == ParsingFunction.EntityReference)
5225 {
5228 return true;
5229 }
5230 return false;
5231 }
5232
5233 private bool ParseText(out int startPos, out int endPos, ref int outOrChars)
5234 {
5235 char[] chars = _ps.chars;
5237 int num = 0;
5238 int num2 = -1;
5239 int num3 = outOrChars;
5240 char c;
5241 while (true)
5242 {
5244 {
5245 num3 |= c;
5246 charRefEndPos++;
5247 continue;
5248 }
5249 switch (c)
5250 {
5251 case '\t':
5252 charRefEndPos++;
5253 continue;
5254 case '\n':
5255 charRefEndPos++;
5257 continue;
5258 case '\r':
5259 if (chars[charRefEndPos + 1] == '\n')
5260 {
5261 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
5262 {
5263 if (charRefEndPos - _ps.charPos > 0)
5264 {
5265 if (num == 0)
5266 {
5267 num = 1;
5269 }
5270 else
5271 {
5272 ShiftBuffer(num2 + num, num2, charRefEndPos - num2 - num);
5273 num2 = charRefEndPos - num;
5274 num++;
5275 }
5276 }
5277 else
5278 {
5279 _ps.charPos++;
5280 }
5281 }
5282 charRefEndPos += 2;
5283 }
5284 else
5285 {
5286 if (charRefEndPos + 1 >= _ps.charsUsed && !_ps.isEof)
5287 {
5288 goto IL_0350;
5289 }
5290 if (!_ps.eolNormalized)
5291 {
5292 chars[charRefEndPos] = '\n';
5293 }
5294 charRefEndPos++;
5295 }
5297 continue;
5298 case '&':
5299 {
5300 int num5;
5302 {
5303 if (num > 0)
5304 {
5305 ShiftBuffer(num2 + num, num2, charRefEndPos - num2 - num);
5306 }
5307 num2 = charRefEndPos - num;
5308 num += num5 - charRefEndPos - charCount;
5310 if (!XmlCharType.IsWhiteSpace(chars[num5 - charCount]) || (_v1Compat && entityType == EntityType.CharacterDec))
5311 {
5312 num3 |= 0xFF;
5313 }
5314 continue;
5315 }
5317 {
5318 break;
5319 }
5321 {
5322 case EntityType.Unexpanded:
5323 break;
5324 case EntityType.CharacterDec:
5325 if (!_v1Compat)
5326 {
5327 goto case EntityType.CharacterHex;
5328 }
5329 num3 |= 0xFF;
5330 goto IL_023f;
5331 case EntityType.CharacterHex:
5332 case EntityType.CharacterNamed:
5334 {
5335 num3 |= 0xFF;
5336 }
5337 goto IL_023f;
5338 default:
5339 {
5341 goto IL_023f;
5342 }
5343 IL_023f:
5344 chars = _ps.chars;
5345 continue;
5346 }
5348 _parsingFunction = ParsingFunction.EntityReference;
5349 goto IL_040d;
5350 }
5351 case ']':
5352 if (_ps.charsUsed - charRefEndPos >= 3 || _ps.isEof)
5353 {
5354 if (chars[charRefEndPos + 1] == ']' && chars[charRefEndPos + 2] == '>')
5355 {
5357 }
5358 num3 |= 0x5D;
5359 charRefEndPos++;
5360 continue;
5361 }
5362 goto IL_0350;
5363 default:
5365 {
5366 char c2 = chars[charRefEndPos];
5368 {
5369 if (charRefEndPos + 1 == _ps.charsUsed)
5370 {
5371 goto IL_0350;
5372 }
5373 charRefEndPos++;
5375 {
5376 charRefEndPos++;
5377 num3 |= c2;
5378 continue;
5379 }
5380 }
5381 int num4 = charRefEndPos - _ps.charPos;
5383 {
5384 chars = _ps.chars;
5386 break;
5387 }
5389 }
5390 goto IL_0350;
5391 case '<':
5392 break;
5393 IL_0350:
5395 {
5396 break;
5397 }
5398 if (ReadData() == 0)
5399 {
5400 if (_ps.charsUsed - _ps.charPos <= 0)
5401 {
5402 if (InEntity)
5403 {
5405 {
5406 goto IL_03f0;
5407 }
5409 _parsingFunction = ParsingFunction.ReportEndEntity;
5410 }
5411 goto IL_040d;
5412 }
5413 if (_ps.chars[_ps.charPos] != '\r' && _ps.chars[_ps.charPos] != ']')
5414 {
5416 }
5417 }
5418 goto IL_03f0;
5419 IL_03f0:
5421 chars = _ps.chars;
5422 continue;
5423 IL_040d:
5425 return true;
5426 }
5427 break;
5428 }
5429 if (_parsingMode == ParsingMode.Full && num > 0)
5430 {
5431 ShiftBuffer(num2 + num, num2, charRefEndPos - num2 - num);
5432 }
5434 endPos = charRefEndPos - num;
5436 outOrChars = num3;
5437 return c == '<';
5438 }
5439
5440 private void FinishPartialValue()
5441 {
5443 int outOrChars = 0;
5444 int startPos;
5445 int endPos;
5446 while (!ParseText(out startPos, out endPos, ref outOrChars))
5447 {
5449 }
5453 }
5454
5456 {
5457 switch (_parsingFunction)
5458 {
5459 case ParsingFunction.InReadValueChunk:
5460 if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue)
5461 {
5463 _incReadState = IncrementalReadState.ReadValueChunk_OnCachedValue;
5464 }
5465 else if (_readValueOffset > 0)
5466 {
5468 _readValueOffset = 0;
5469 }
5470 break;
5471 case ParsingFunction.InReadContentAsBinary:
5472 case ParsingFunction.InReadElementContentAsBinary:
5473 switch (_incReadState)
5474 {
5475 case IncrementalReadState.ReadContentAsBinary_OnPartialValue:
5477 _incReadState = IncrementalReadState.ReadContentAsBinary_OnCachedValue;
5478 break;
5479 case IncrementalReadState.ReadContentAsBinary_OnCachedValue:
5480 if (_readValueOffset > 0)
5481 {
5483 _readValueOffset = 0;
5484 }
5485 break;
5486 case IncrementalReadState.ReadContentAsBinary_End:
5487 _curNode.SetValue(string.Empty);
5488 break;
5489 }
5490 break;
5491 case ParsingFunction.InReadAttributeValue:
5492 break;
5493 }
5494 }
5495
5496 [MethodImpl(MethodImplOptions.NoInlining)]
5498 {
5499 int outOrChars = 0;
5501 int startPos;
5502 int endPos;
5503 while (!ParseText(out startPos, out endPos, ref outOrChars))
5504 {
5505 }
5506 }
5507
5509 {
5510 _readValueOffset = 0;
5511 if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue)
5512 {
5514 return;
5515 }
5518 }
5519
5521 {
5522 _readValueOffset = 0;
5523 if (_incReadState == IncrementalReadState.ReadContentAsBinary_OnPartialValue)
5524 {
5526 }
5527 else
5528 {
5531 }
5532 if (_incReadState != IncrementalReadState.ReadContentAsBinary_End)
5533 {
5535 {
5536 }
5537 }
5538 }
5539
5541 {
5543 if (_curNode.type != XmlNodeType.EndElement)
5544 {
5546 }
5548 }
5549
5551 {
5553 if (whitespaceType == XmlNodeType.None)
5554 {
5555 EatWhitespaces(null);
5557 {
5558 return false;
5559 }
5560 }
5561 else
5562 {
5566 {
5567 if (_stringBuilder.Length > 0)
5568 {
5571 return true;
5572 }
5573 return false;
5574 }
5575 }
5577 {
5579 }
5580 else
5581 {
5583 }
5584 return false;
5585 }
5586
5588 {
5589 _ps.charPos++;
5592 }
5593
5595 {
5596 if (_ps.charPos + 1 == _ps.charsUsed && ReadData() == 0)
5597 {
5599 }
5600 if (_ps.chars[_ps.charPos + 1] == '#')
5601 {
5603 return entityType;
5604 }
5606 if (charRefEndPos >= 0)
5607 {
5608 return EntityType.CharacterNamed;
5609 }
5611 {
5612 return EntityType.Unexpanded;
5613 }
5614 _ps.charPos++;
5615 int linePos = _ps.LinePos;
5616 int num;
5617 try
5618 {
5619 num = ParseName();
5620 }
5621 catch (XmlException)
5622 {
5624 return EntityType.Skipped;
5625 }
5626 if (_ps.chars[num] != ';')
5627 {
5628 ThrowUnexpectedToken(num, ";");
5629 }
5630 int linePos2 = _ps.LinePos;
5631 string name = _nameTable.Add(_ps.chars, _ps.charPos, num - _ps.charPos);
5632 _ps.charPos = num + 1;
5633 charRefEndPos = -1;
5637 return result;
5638 }
5639
5641 {
5644 {
5646 }
5647 if (_dtdInfo == null || (dtdEntityInfo = _dtdInfo.LookupEntity(name)) == null)
5648 {
5650 {
5652 schemaEntity.Text = string.Empty;
5654 }
5655 else
5656 {
5658 }
5659 }
5660 if (dtdEntityInfo.IsUnparsedEntity)
5661 {
5663 {
5665 schemaEntity2.Text = string.Empty;
5667 }
5668 else
5669 {
5671 }
5672 }
5673 if (_standalone && dtdEntityInfo.IsDeclaredInExternal)
5674 {
5676 }
5677 if (dtdEntityInfo.IsExternal)
5678 {
5680 {
5682 return EntityType.Skipped;
5683 }
5684 if (_parsingMode == ParsingMode.SkipContent)
5685 {
5686 return EntityType.Skipped;
5687 }
5688 if (IsResolverNull)
5689 {
5691 {
5694 return EntityType.FakeExpanded;
5695 }
5696 return EntityType.Skipped;
5697 }
5701 {
5702 return EntityType.Expanded;
5703 }
5704 return EntityType.ExpandedInAttribute;
5705 }
5706 if (_parsingMode == ParsingMode.SkipContent)
5707 {
5708 return EntityType.Skipped;
5709 }
5713 {
5714 return EntityType.Expanded;
5715 }
5716 return EntityType.ExpandedInAttribute;
5717 }
5718
5720 {
5721 if (_parsingStatesStackTop == -1)
5722 {
5724 }
5726 {
5727 _index--;
5729 {
5731 }
5733 PopEntity();
5734 return true;
5735 }
5737 {
5739 }
5740 PopEntity();
5743 return false;
5744 }
5745
5747 {
5753 if (_index == 0 && _parsingFunction == ParsingFunction.ElementContent)
5754 {
5755 _parsingFunction = ParsingFunction.DocumentContent;
5756 }
5757 }
5758
5760 {
5763 _curNode.type = XmlNodeType.EndEntity;
5764 }
5765
5766 private bool ParsePI()
5767 {
5768 return ParsePI(null);
5769 }
5770
5772 {
5773 if (_parsingMode == ParsingMode.Full)
5774 {
5776 }
5777 int num = ParseName();
5778 string text = _nameTable.Add(_ps.chars, _ps.charPos, num - _ps.charPos);
5779 if (string.Equals(text, "xml", StringComparison.OrdinalIgnoreCase))
5780 {
5782 }
5783 _ps.charPos = num;
5784 if (piInDtdStringBuilder == null)
5785 {
5786 if (!_ignorePIs && _parsingMode == ParsingMode.Full)
5787 {
5788 _curNode.SetNamedNode(XmlNodeType.ProcessingInstruction, text);
5789 }
5790 }
5791 else
5792 {
5793 piInDtdStringBuilder.Append(text);
5794 }
5795 char c = _ps.chars[_ps.charPos];
5797 {
5798 if (_ps.charsUsed - _ps.charPos < 2)
5799 {
5800 ReadData();
5801 }
5802 if (c != '?' || _ps.chars[_ps.charPos + 1] != '>')
5803 {
5805 }
5806 }
5808 {
5809 if (piInDtdStringBuilder == null)
5810 {
5811 if (_ignorePIs)
5812 {
5813 return false;
5814 }
5815 if (_parsingMode == ParsingMode.Full)
5816 {
5818 }
5819 }
5820 else
5821 {
5823 }
5824 }
5825 else
5826 {
5828 if (piInDtdStringBuilder == null)
5829 {
5830 if (_ignorePIs || _parsingMode != 0)
5831 {
5833 {
5834 }
5835 return false;
5836 }
5838 }
5839 else
5840 {
5842 }
5843 do
5844 {
5846 }
5849 if (piInDtdStringBuilder == null)
5850 {
5853 }
5854 }
5855 return true;
5856 }
5857
5859 {
5860 if (_ps.charsUsed - _ps.charPos < 2 && ReadData() == 0)
5861 {
5863 }
5864 int num = _ps.charPos;
5865 char[] chars = _ps.chars;
5866 int num2 = 0;
5867 int num3 = -1;
5868 while (true)
5869 {
5870 char c;
5871 if (XmlCharType.IsTextChar(c = chars[num]) && c != '?')
5872 {
5873 num++;
5874 continue;
5875 }
5876 switch (chars[num])
5877 {
5878 case '?':
5879 if (chars[num + 1] == '>')
5880 {
5881 if (num2 > 0)
5882 {
5883 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
5884 outEndPos = num - num2;
5885 }
5886 else
5887 {
5888 outEndPos = num;
5889 }
5891 _ps.charPos = num + 2;
5892 return true;
5893 }
5894 if (num + 1 != _ps.charsUsed)
5895 {
5896 num++;
5897 continue;
5898 }
5899 break;
5900 case '\n':
5901 num++;
5902 OnNewLine(num);
5903 continue;
5904 case '\r':
5905 if (chars[num + 1] == '\n')
5906 {
5907 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
5908 {
5909 if (num - _ps.charPos > 0)
5910 {
5911 if (num2 == 0)
5912 {
5913 num2 = 1;
5914 num3 = num;
5915 }
5916 else
5917 {
5918 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
5919 num3 = num - num2;
5920 num2++;
5921 }
5922 }
5923 else
5924 {
5925 _ps.charPos++;
5926 }
5927 }
5928 num += 2;
5929 }
5930 else
5931 {
5932 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
5933 {
5934 break;
5935 }
5936 if (!_ps.eolNormalized)
5937 {
5938 chars[num] = '\n';
5939 }
5940 num++;
5941 }
5942 OnNewLine(num);
5943 continue;
5944 case '\t':
5945 case '&':
5946 case '<':
5947 case ']':
5948 num++;
5949 continue;
5950 default:
5951 {
5952 if (num == _ps.charsUsed)
5953 {
5954 break;
5955 }
5956 char ch = chars[num];
5958 {
5959 if (num + 1 == _ps.charsUsed)
5960 {
5961 break;
5962 }
5963 num++;
5965 {
5966 num++;
5967 continue;
5968 }
5969 }
5971 continue;
5972 }
5973 }
5974 break;
5975 }
5976 if (num2 > 0)
5977 {
5978 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
5979 outEndPos = num - num2;
5980 }
5981 else
5982 {
5983 outEndPos = num;
5984 }
5986 _ps.charPos = num;
5987 return false;
5988 }
5989
5990 private bool ParseComment()
5991 {
5992 if (_ignoreComments)
5993 {
5995 _parsingMode = ParsingMode.SkipNode;
5998 return false;
5999 }
6001 return true;
6002 }
6003
6004 private void ParseCData()
6005 {
6007 }
6008
6037
6039 {
6040 if (_ps.charsUsed - _ps.charPos < 3 && ReadData() == 0)
6041 {
6042 Throw(System.SR.Xml_UnexpectedEOF, (type == XmlNodeType.Comment) ? "Comment" : "CDATA");
6043 }
6044 int num = _ps.charPos;
6045 char[] chars = _ps.chars;
6046 int num2 = 0;
6047 int num3 = -1;
6048 char c = ((type == XmlNodeType.Comment) ? '-' : ']');
6049 while (true)
6050 {
6051 char c2;
6052 if (XmlCharType.IsTextChar(c2 = chars[num]) && c2 != c)
6053 {
6054 num++;
6055 continue;
6056 }
6057 if (chars[num] == c)
6058 {
6059 if (chars[num + 1] == c)
6060 {
6061 if (chars[num + 2] == '>')
6062 {
6063 if (num2 > 0)
6064 {
6065 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
6066 outEndPos = num - num2;
6067 }
6068 else
6069 {
6070 outEndPos = num;
6071 }
6073 _ps.charPos = num + 3;
6074 return true;
6075 }
6076 if (num + 2 == _ps.charsUsed)
6077 {
6078 break;
6079 }
6080 if (type == XmlNodeType.Comment)
6081 {
6083 }
6084 }
6085 else if (num + 1 == _ps.charsUsed)
6086 {
6087 break;
6088 }
6089 num++;
6090 continue;
6091 }
6092 switch (chars[num])
6093 {
6094 case '\n':
6095 num++;
6096 OnNewLine(num);
6097 continue;
6098 case '\r':
6099 if (chars[num + 1] == '\n')
6100 {
6101 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
6102 {
6103 if (num - _ps.charPos > 0)
6104 {
6105 if (num2 == 0)
6106 {
6107 num2 = 1;
6108 num3 = num;
6109 }
6110 else
6111 {
6112 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
6113 num3 = num - num2;
6114 num2++;
6115 }
6116 }
6117 else
6118 {
6119 _ps.charPos++;
6120 }
6121 }
6122 num += 2;
6123 }
6124 else
6125 {
6126 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
6127 {
6128 break;
6129 }
6130 if (!_ps.eolNormalized)
6131 {
6132 chars[num] = '\n';
6133 }
6134 num++;
6135 }
6136 OnNewLine(num);
6137 continue;
6138 case '\t':
6139 case '&':
6140 case '<':
6141 case ']':
6142 num++;
6143 continue;
6144 default:
6145 {
6146 if (num == _ps.charsUsed)
6147 {
6148 break;
6149 }
6150 char ch = chars[num];
6152 {
6153 if (num + 1 == _ps.charsUsed)
6154 {
6155 break;
6156 }
6157 num++;
6159 {
6160 num++;
6161 continue;
6162 }
6163 }
6165 break;
6166 }
6167 }
6168 break;
6169 }
6170 if (num2 > 0)
6171 {
6172 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
6173 outEndPos = num - num2;
6174 }
6175 else
6176 {
6177 outEndPos = num;
6178 }
6180 _ps.charPos = num;
6181 return false;
6182 }
6183
6184 private bool ParseDoctypeDecl()
6185 {
6186 if (_dtdProcessing == DtdProcessing.Prohibit)
6187 {
6189 }
6190 while (_ps.charsUsed - _ps.charPos < 8)
6191 {
6192 if (ReadData() == 0)
6193 {
6194 Throw(System.SR.Xml_UnexpectedEOF, "DOCTYPE");
6195 }
6196 }
6197 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, 7, "DOCTYPE"))
6198 {
6199 ThrowUnexpectedToken((!_rootElementParsed && _dtdInfo == null) ? "DOCTYPE" : "<!--");
6200 }
6202 {
6204 }
6205 if (_dtdInfo != null)
6206 {
6208 }
6210 {
6212 }
6213 _ps.charPos += 8;
6214 EatWhitespaces(null);
6215 if (_dtdProcessing == DtdProcessing.Parse)
6216 {
6218 ParseDtd();
6220 _parsingFunction = ParsingFunction.ResetAttributesRootLevel;
6221 return true;
6222 }
6223 SkipDtd();
6224 return false;
6225 }
6226
6238
6239 private void SkipDtd()
6240 {
6241 int colonPos;
6242 int charPos = ParseQName(out colonPos);
6243 _ps.charPos = charPos;
6244 EatWhitespaces(null);
6245 if (_ps.chars[_ps.charPos] == 'P')
6246 {
6247 while (_ps.charsUsed - _ps.charPos < 6)
6248 {
6249 if (ReadData() == 0)
6250 {
6252 }
6253 }
6254 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, 6, "PUBLIC"))
6255 {
6256 ThrowUnexpectedToken("PUBLIC");
6257 }
6258 _ps.charPos += 6;
6259 if (EatWhitespaces(null) == 0)
6260 {
6262 }
6264 if (EatWhitespaces(null) == 0)
6265 {
6267 }
6269 EatWhitespaces(null);
6270 }
6271 else if (_ps.chars[_ps.charPos] == 'S')
6272 {
6273 while (_ps.charsUsed - _ps.charPos < 6)
6274 {
6275 if (ReadData() == 0)
6276 {
6278 }
6279 }
6280 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, 6, "SYSTEM"))
6281 {
6282 ThrowUnexpectedToken("SYSTEM");
6283 }
6284 _ps.charPos += 6;
6285 if (EatWhitespaces(null) == 0)
6286 {
6288 }
6290 EatWhitespaces(null);
6291 }
6292 else if (_ps.chars[_ps.charPos] != '[' && _ps.chars[_ps.charPos] != '>')
6293 {
6295 }
6296 if (_ps.chars[_ps.charPos] == '[')
6297 {
6298 _ps.charPos++;
6299 SkipUntil(']', recognizeLiterals: true);
6300 EatWhitespaces(null);
6301 if (_ps.chars[_ps.charPos] != '>')
6302 {
6304 }
6305 }
6306 else if (_ps.chars[_ps.charPos] == '>')
6307 {
6308 _curNode.SetValue(string.Empty);
6309 }
6310 else
6311 {
6313 }
6314 _ps.charPos++;
6315 }
6316
6318 {
6319 char c = _ps.chars[_ps.charPos];
6320 if (c != '"' && c != '\'')
6321 {
6322 ThrowUnexpectedToken("\"", "'");
6323 }
6324 _ps.charPos++;
6325 SkipUntil(c, recognizeLiterals: false);
6326 }
6327
6328 private void SkipUntil(char stopChar, bool recognizeLiterals)
6329 {
6330 bool flag = false;
6331 bool flag2 = false;
6332 bool flag3 = false;
6333 char c = '"';
6334 char[] chars = _ps.chars;
6335 int num = _ps.charPos;
6336 while (true)
6337 {
6338 char c2;
6339 if (XmlCharType.IsAttributeValueChar(c2 = chars[num]) && chars[num] != stopChar && c2 != '-' && c2 != '?')
6340 {
6341 num++;
6342 continue;
6343 }
6344 if (c2 == stopChar && !flag)
6345 {
6346 break;
6347 }
6348 _ps.charPos = num;
6349 switch (c2)
6350 {
6351 case '\n':
6352 num++;
6353 OnNewLine(num);
6354 continue;
6355 case '\r':
6356 if (chars[num + 1] == '\n')
6357 {
6358 num += 2;
6359 }
6360 else
6361 {
6362 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
6363 {
6364 break;
6365 }
6366 num++;
6367 }
6368 OnNewLine(num);
6369 continue;
6370 case '<':
6371 if (chars[num + 1] == '?')
6372 {
6373 if (recognizeLiterals && !flag && !flag2)
6374 {
6375 flag3 = true;
6376 num += 2;
6377 continue;
6378 }
6379 }
6380 else if (chars[num + 1] == '!')
6381 {
6382 if (num + 3 >= _ps.charsUsed && !_ps.isEof)
6383 {
6384 break;
6385 }
6386 if (chars[num + 2] == '-' && chars[num + 3] == '-' && recognizeLiterals && !flag && !flag3)
6387 {
6388 flag2 = true;
6389 num += 4;
6390 continue;
6391 }
6392 }
6393 else if (num + 1 >= _ps.charsUsed && !_ps.isEof)
6394 {
6395 break;
6396 }
6397 num++;
6398 continue;
6399 case '-':
6400 if (flag2)
6401 {
6402 if (num + 2 >= _ps.charsUsed && !_ps.isEof)
6403 {
6404 break;
6405 }
6406 if (chars[num + 1] == '-' && chars[num + 2] == '>')
6407 {
6408 flag2 = false;
6409 num += 2;
6410 continue;
6411 }
6412 }
6413 num++;
6414 continue;
6415 case '?':
6416 if (flag3)
6417 {
6418 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
6419 {
6420 break;
6421 }
6422 if (chars[num + 1] == '>')
6423 {
6424 flag3 = false;
6425 num++;
6426 continue;
6427 }
6428 }
6429 num++;
6430 continue;
6431 case '\t':
6432 case '&':
6433 case '>':
6434 case ']':
6435 num++;
6436 continue;
6437 case '"':
6438 case '\'':
6439 if (flag)
6440 {
6441 if (c == c2)
6442 {
6443 flag = false;
6444 }
6445 }
6446 else if (recognizeLiterals && !flag2 && !flag3)
6447 {
6448 flag = true;
6449 c = c2;
6450 }
6451 num++;
6452 continue;
6453 default:
6454 {
6455 if (num == _ps.charsUsed)
6456 {
6457 break;
6458 }
6459 char ch = chars[num];
6461 {
6462 if (num + 1 == _ps.charsUsed)
6463 {
6464 break;
6465 }
6466 num++;
6468 {
6469 num++;
6470 continue;
6471 }
6472 }
6474 break;
6475 }
6476 }
6477 if (ReadData() == 0)
6478 {
6479 if (_ps.charsUsed - _ps.charPos > 0)
6480 {
6481 if (_ps.chars[_ps.charPos] != '\r')
6482 {
6484 }
6485 }
6486 else
6487 {
6489 }
6490 }
6491 chars = _ps.chars;
6492 num = _ps.charPos;
6493 }
6494 _ps.charPos = num + 1;
6495 }
6496
6498 {
6499 int num = _ps.charPos;
6500 int num2 = 0;
6501 char[] chars = _ps.chars;
6502 while (true)
6503 {
6504 switch (chars[num])
6505 {
6506 case '\n':
6507 num++;
6508 OnNewLine(num);
6509 continue;
6510 case '\r':
6511 if (chars[num + 1] == '\n')
6512 {
6513 int num4 = num - _ps.charPos;
6514 if (sb != null && !_ps.eolNormalized)
6515 {
6516 if (num4 > 0)
6517 {
6518 sb.Append(chars, _ps.charPos, num4);
6519 num2 += num4;
6520 }
6521 _ps.charPos = num + 1;
6522 }
6523 num += 2;
6524 }
6525 else
6526 {
6527 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
6528 {
6529 break;
6530 }
6531 if (!_ps.eolNormalized)
6532 {
6533 chars[num] = '\n';
6534 }
6535 num++;
6536 }
6537 OnNewLine(num);
6538 continue;
6539 case '\t':
6540 case ' ':
6541 num++;
6542 continue;
6543 default:
6544 if (num != _ps.charsUsed)
6545 {
6546 int num3 = num - _ps.charPos;
6547 if (num3 > 0)
6548 {
6549 sb?.Append(_ps.chars, _ps.charPos, num3);
6550 _ps.charPos = num;
6551 num2 += num3;
6552 }
6553 return num2;
6554 }
6555 break;
6556 }
6557 int num5 = num - _ps.charPos;
6558 if (num5 > 0)
6559 {
6560 sb?.Append(_ps.chars, _ps.charPos, num5);
6561 _ps.charPos = num;
6562 num2 += num5;
6563 }
6564 if (ReadData() == 0)
6565 {
6566 if (_ps.charsUsed - _ps.charPos == 0)
6567 {
6568 break;
6569 }
6570 if (_ps.chars[_ps.charPos] != '\r')
6571 {
6573 }
6574 }
6575 num = _ps.charPos;
6576 chars = _ps.chars;
6577 }
6578 return num2;
6579 }
6580
6582 {
6583 if (_ps.chars[startPos + 1] == '#')
6584 {
6585 return ParseNumericCharRefInline(startPos, expand: true, null, out charCount, out entityType);
6586 }
6587 charCount = 1;
6588 entityType = EntityType.CharacterNamed;
6589 return ParseNamedCharRefInline(startPos, expand: true, null);
6590 }
6591
6593 {
6594 int num;
6595 int charCount;
6596 while (true)
6597 {
6599 if (num2 != -2)
6600 {
6601 break;
6602 }
6603 if (ReadData() == 0)
6604 {
6606 }
6607 }
6608 if (expand)
6609 {
6610 _ps.charPos = num - charCount;
6611 }
6612 return num;
6613 }
6614
6616 {
6617 int num = 0;
6618 string res = null;
6619 char[] chars = _ps.chars;
6620 int i = startPos + 2;
6621 charCount = 0;
6622 int num2 = 0;
6623 try
6624 {
6625 if (chars[i] == 'x')
6626 {
6627 i++;
6628 num2 = i;
6630 while (true)
6631 {
6633 if (num3 == 255)
6634 {
6635 break;
6636 }
6637 num = checked(num * 16 + num3);
6638 i++;
6639 }
6640 entityType = EntityType.CharacterHex;
6641 }
6642 else
6643 {
6644 if (i >= _ps.charsUsed)
6645 {
6646 entityType = EntityType.Skipped;
6647 return -2;
6648 }
6649 num2 = i;
6651 for (; chars[i] >= '0' && chars[i] <= '9'; i++)
6652 {
6653 num = checked(num * 10 + chars[i] - 48);
6654 }
6655 entityType = EntityType.CharacterDec;
6656 }
6657 }
6659 {
6660 _ps.charPos = i;
6661 entityType = EntityType.Skipped;
6663 }
6664 if (chars[i] != ';' || num2 == i)
6665 {
6666 if (i == _ps.charsUsed)
6667 {
6668 return -2;
6669 }
6670 Throw(i, res);
6671 }
6672 if (num <= 65535)
6673 {
6674 char c = (char)num;
6676 {
6678 }
6679 if (expand)
6680 {
6682 chars[i] = c;
6683 }
6684 charCount = 1;
6685 return i + 1;
6686 }
6689 {
6691 }
6692 if (expand)
6693 {
6695 chars[i - 1] = highChar;
6696 chars[i] = lowChar;
6697 }
6698 charCount = 2;
6699 return i + 1;
6700 }
6701
6703 {
6704 do
6705 {
6706 int num;
6708 {
6709 case -1:
6710 return -1;
6711 case -2:
6712 continue;
6713 }
6714 if (expand)
6715 {
6716 _ps.charPos = num - 1;
6717 }
6718 return num;
6719 }
6720 while (ReadData() != 0);
6721 return -1;
6722 }
6723
6725 {
6726 int num = startPos + 1;
6727 char[] chars = _ps.chars;
6728 char c = chars[num];
6729 char c2;
6730 if ((uint)c <= 103u)
6731 {
6732 if (c != 'a')
6733 {
6734 if (c != 'g')
6735 {
6736 goto IL_0170;
6737 }
6738 if (_ps.charsUsed - num >= 3)
6739 {
6740 if (chars[num + 1] == 't' && chars[num + 2] == ';')
6741 {
6742 num += 3;
6743 c2 = '>';
6744 goto IL_0175;
6745 }
6746 return -1;
6747 }
6748 }
6749 else
6750 {
6751 num++;
6752 if (chars[num] == 'm')
6753 {
6754 if (_ps.charsUsed - num >= 3)
6755 {
6756 if (chars[num + 1] == 'p' && chars[num + 2] == ';')
6757 {
6758 num += 3;
6759 c2 = '&';
6760 goto IL_0175;
6761 }
6762 return -1;
6763 }
6764 }
6765 else if (chars[num] == 'p')
6766 {
6767 if (_ps.charsUsed - num >= 4)
6768 {
6769 if (chars[num + 1] == 'o' && chars[num + 2] == 's' && chars[num + 3] == ';')
6770 {
6771 num += 4;
6772 c2 = '\'';
6773 goto IL_0175;
6774 }
6775 return -1;
6776 }
6777 }
6778 else if (num < _ps.charsUsed)
6779 {
6780 return -1;
6781 }
6782 }
6783 goto IL_0172;
6784 }
6785 if (c != 'l')
6786 {
6787 if (c != 'q')
6788 {
6789 goto IL_0170;
6790 }
6791 if (_ps.charsUsed - num < 5)
6792 {
6793 goto IL_0172;
6794 }
6795 if (chars[num + 1] != 'u' || chars[num + 2] != 'o' || chars[num + 3] != 't' || chars[num + 4] != ';')
6796 {
6797 return -1;
6798 }
6799 num += 5;
6800 c2 = '"';
6801 }
6802 else
6803 {
6804 if (_ps.charsUsed - num < 3)
6805 {
6806 goto IL_0172;
6807 }
6808 if (chars[num + 1] != 't' || chars[num + 2] != ';')
6809 {
6810 return -1;
6811 }
6812 num += 3;
6813 c2 = '<';
6814 }
6815 goto IL_0175;
6816 IL_0170:
6817 return -1;
6818 IL_0172:
6819 return -2;
6820 IL_0175:
6821 if (expand)
6822 {
6824 _ps.chars[num - 1] = c2;
6825 }
6826 return num;
6827 }
6828
6829 private int ParseName()
6830 {
6831 int colonPos;
6832 return ParseQName(isQName: false, 0, out colonPos);
6833 }
6834
6835 private int ParseQName(out int colonPos)
6836 {
6837 return ParseQName(isQName: true, 0, out colonPos);
6838 }
6839
6840 private int ParseQName(bool isQName, int startOffset, out int colonPos)
6841 {
6842 int num = -1;
6843 int pos = _ps.charPos + startOffset;
6844 while (true)
6845 {
6846 char[] chars = _ps.chars;
6848 {
6849 pos++;
6850 }
6851 else
6852 {
6853 if (pos + 1 >= _ps.charsUsed)
6854 {
6855 if (ReadDataInName(ref pos))
6856 {
6857 continue;
6858 }
6859 Throw(pos, System.SR.Xml_UnexpectedEOF, "Name");
6860 }
6861 if (chars[pos] != ':' || _supportNamespaces)
6862 {
6864 }
6865 }
6866 while (true)
6867 {
6869 {
6870 pos++;
6871 continue;
6872 }
6873 if (chars[pos] == ':')
6874 {
6876 {
6877 break;
6878 }
6879 num = pos - _ps.charPos;
6880 pos++;
6881 continue;
6882 }
6883 if (pos == _ps.charsUsed)
6884 {
6885 if (ReadDataInName(ref pos))
6886 {
6887 chars = _ps.chars;
6888 continue;
6889 }
6890 Throw(pos, System.SR.Xml_UnexpectedEOF, "Name");
6891 }
6892 colonPos = ((num == -1) ? (-1) : (_ps.charPos + num));
6893 return pos;
6894 }
6895 if (num != -1 || !isQName)
6896 {
6898 }
6899 num = pos - _ps.charPos;
6900 pos++;
6901 }
6902 }
6903
6904 private bool ReadDataInName(ref int pos)
6905 {
6906 int num = pos - _ps.charPos;
6907 bool result = ReadData() != 0;
6908 pos = _ps.charPos + num;
6909 return result;
6910 }
6911
6912 private string ParseEntityName()
6913 {
6914 int num;
6915 try
6916 {
6917 num = ParseName();
6918 }
6919 catch (XmlException)
6920 {
6922 return null;
6923 }
6924 if (_ps.chars[num] != ';')
6925 {
6927 }
6928 string result = _nameTable.Add(_ps.chars, _ps.charPos, num - _ps.charPos);
6929 _ps.charPos = num + 1;
6930 return result;
6931 }
6932
6934 {
6936 if (nodeData != null)
6937 {
6939 return nodeData;
6940 }
6941 return AllocNode(nodeIndex, nodeDepth);
6942 }
6943
6945 {
6946 if (nodeIndex >= _nodes.Length - 1)
6947 {
6948 NodeData[] array = new NodeData[_nodes.Length * 2];
6949 Array.Copy(_nodes, array, _nodes.Length);
6950 _nodes = array;
6951 }
6953 if (nodeData == null)
6954 {
6955 nodeData = new NodeData();
6957 }
6959 return nodeData;
6960 }
6961
6962 private NodeData AddAttributeNoChecks(string name, int attrDepth)
6963 {
6965 nodeData.SetNamedNode(XmlNodeType.Attribute, _nameTable.Add(name));
6966 _attrCount++;
6967 return nodeData;
6968 }
6969
6971 {
6972 if (colonPos == -1 || !_supportNamespaces)
6973 {
6975 return AddAttribute(text, string.Empty, text);
6976 }
6978 int charPos = _ps.charPos;
6979 int num = colonPos - charPos;
6980 if (num != _lastPrefix.Length || !XmlConvert.StrEqual(_ps.chars, charPos, num, _lastPrefix))
6981 {
6982 return AddAttribute(prefix: _lastPrefix = _nameTable.Add(_ps.chars, charPos, num), localName: _nameTable.Add(_ps.chars, colonPos + 1, endNamePos - colonPos - 1), nameWPrefix: null);
6983 }
6985 }
6986
6987 private NodeData AddAttribute(string localName, string prefix, string nameWPrefix)
6988 {
6990 nodeData.SetNamedNode(XmlNodeType.Attribute, localName, prefix, nameWPrefix);
6991 int num = 1 << (localName[0] & 0x1F);
6992 if ((_attrHashtable & num) == 0)
6993 {
6994 _attrHashtable |= num;
6995 }
6996 else if (_attrDuplWalkCount < 250)
6997 {
6999 for (int i = _index + 1; i < _index + _attrCount + 1; i++)
7000 {
7002 if (Ref.Equal(nodeData2.localName, nodeData.localName))
7003 {
7004 _attrDuplWalkCount = 250;
7005 break;
7006 }
7007 }
7008 }
7009 _attrCount++;
7010 return nodeData;
7011 }
7012
7013 private void PopElementContext()
7014 {
7017 {
7018 PopXmlContext();
7019 }
7020 }
7021
7022 private void OnNewLine(int pos)
7023 {
7024 _ps.lineNo++;
7025 _ps.lineStartPos = pos - 1;
7026 }
7027
7028 private void OnEof()
7029 {
7030 _curNode = _nodes[0];
7034 _readState = ReadState.EndOfFile;
7035 _reportedEncoding = null;
7036 }
7037
7039 {
7040 string text = _namespaceManager.LookupNamespace(node.prefix);
7041 if (text != null)
7042 {
7043 return text;
7044 }
7045 Throw(System.SR.Xml_UnknownNs, node.prefix, node.LineNo, node.LinePos);
7046 return null;
7047 }
7048
7049 private void AddNamespace(string prefix, string uri, NodeData attr)
7050 {
7051 if (uri == "http://www.w3.org/2000/xmlns/")
7052 {
7053 if (Ref.Equal(prefix, _xmlNs))
7054 {
7055 Throw(System.SR.Xml_XmlnsPrefix, attr.lineInfo2.lineNo, attr.lineInfo2.linePos);
7056 }
7057 else
7058 {
7059 Throw(System.SR.Xml_NamespaceDeclXmlXmlns, prefix, attr.lineInfo2.lineNo, attr.lineInfo2.linePos);
7060 }
7061 }
7062 else if (uri == "http://www.w3.org/XML/1998/namespace" && !Ref.Equal(prefix, _xml) && !_v1Compat)
7063 {
7064 Throw(System.SR.Xml_NamespaceDeclXmlXmlns, prefix, attr.lineInfo2.lineNo, attr.lineInfo2.linePos);
7065 }
7066 if (uri.Length == 0 && prefix.Length > 0)
7067 {
7068 Throw(System.SR.Xml_BadNamespaceDecl, attr.lineInfo.lineNo, attr.lineInfo.linePos);
7069 }
7070 try
7071 {
7073 }
7074 catch (ArgumentException e)
7075 {
7076 ReThrow(e, attr.lineInfo.lineNo, attr.lineInfo.linePos);
7077 }
7078 }
7079
7080 private void ResetAttributes()
7081 {
7082 if (_fullAttrCleanup)
7083 {
7085 }
7086 _curAttrIndex = -1;
7087 _attrCount = 0;
7088 _attrHashtable = 0;
7090 }
7091
7093 {
7094 for (int i = _index + 1; i < _index + _attrCount + 1; i++)
7095 {
7099 }
7100 _fullAttrCleanup = false;
7101 }
7102
7103 private void PushXmlContext()
7104 {
7107 }
7108
7109 private void PopXmlContext()
7110 {
7113 }
7114
7116 {
7118 {
7119 if (_xmlContext.xmlSpace == XmlSpace.Preserve)
7120 {
7121 return XmlNodeType.SignificantWhitespace;
7122 }
7124 {
7125 return XmlNodeType.Whitespace;
7126 }
7127 }
7128 return XmlNodeType.None;
7129 }
7130
7131 private XmlNodeType GetTextNodeType(int orChars)
7132 {
7133 if (orChars > 32)
7134 {
7135 return XmlNodeType.Text;
7136 }
7137 return GetWhitespaceType();
7138 }
7139
7140 private void PushExternalEntityOrSubset(string publicId, string systemId, Uri baseUri, string entityName)
7141 {
7142 Uri uri;
7143 if (!string.IsNullOrEmpty(publicId))
7144 {
7145 try
7146 {
7147 uri = _xmlResolver.ResolveUri(baseUri, publicId);
7148 if (OpenAndPush(uri))
7149 {
7150 return;
7151 }
7152 }
7153 catch (Exception)
7154 {
7155 }
7156 }
7157 uri = _xmlResolver.ResolveUri(baseUri, systemId);
7158 try
7159 {
7160 if (OpenAndPush(uri))
7161 {
7162 return;
7163 }
7164 }
7165 catch (Exception ex2)
7166 {
7167 if (_v1Compat)
7168 {
7169 throw;
7170 }
7171 string message = ex2.Message;
7173 {
7174 uri.ToString(),
7175 message
7176 }, ex2, 0, 0));
7177 }
7178 if (entityName == null)
7179 {
7181 {
7182 (publicId != null) ? publicId : string.Empty,
7183 systemId
7184 }, null);
7185 }
7186 else
7187 {
7189 }
7190 }
7191
7192 private bool OpenAndPush(Uri uri)
7193 {
7195 {
7196 TextReader textReader = (TextReader)_xmlResolver.GetEntity(uri, null, typeof(TextReader));
7197 if (textReader == null)
7198 {
7199 return false;
7200 }
7202 InitTextReaderInput(uri.ToString(), uri, textReader);
7203 }
7204 else
7205 {
7207 if (stream == null)
7208 {
7209 return false;
7210 }
7212 InitStreamInput(uri, stream, null);
7213 }
7214 return true;
7215 }
7216
7218 {
7219 if (!IsResolverNull)
7220 {
7221 Uri baseUri = null;
7222 if (!string.IsNullOrEmpty(entity.BaseUriString))
7223 {
7224 baseUri = _xmlResolver.ResolveUri(null, entity.BaseUriString);
7225 }
7226 PushExternalEntityOrSubset(entity.PublicId, entity.SystemId, baseUri, entity.Name);
7227 RegisterEntity(entity);
7228 int charPos = _ps.charPos;
7229 if (_v1Compat)
7230 {
7231 EatWhitespaces(null);
7232 }
7233 if (!ParseXmlDeclaration(isTextDecl: true))
7234 {
7235 _ps.charPos = charPos;
7236 }
7237 return true;
7238 }
7239 Encoding encoding = _ps.encoding;
7241 InitStringInput(entity.SystemId, encoding, string.Empty);
7242 RegisterEntity(entity);
7244 return false;
7245 }
7246
7248 {
7249 Encoding encoding = _ps.encoding;
7251 InitStringInput(entity.DeclaredUriString ?? string.Empty, encoding, entity.Text);
7252 RegisterEntity(entity);
7253 _ps.lineNo = entity.LineNumber;
7255 _ps.eolNormalized = true;
7257 }
7258
7259 private void PopEntity()
7260 {
7261 if (_ps.stream != null)
7262 {
7263 _ps.stream.Dispose();
7264 }
7268 }
7269
7270 private void RegisterEntity(IDtdEntityInfo entity)
7271 {
7272 if (_currentEntities != null && _currentEntities.ContainsKey(entity))
7273 {
7275 }
7276 _ps.entity = entity;
7278 if (entity != null)
7279 {
7280 if (_currentEntities == null)
7281 {
7283 }
7284 _currentEntities.Add(entity, entity);
7285 }
7286 }
7287
7288 private void UnregisterEntity()
7289 {
7290 if (_ps.entity != null)
7291 {
7293 }
7294 }
7295
7312
7313 private void PopParsingState()
7314 {
7315 _ps.Close(closeInput: true);
7317 }
7318
7320 {
7322 decoder.Reset();
7323 _incReadDecoder = decoder;
7325 _incReadDepth = 1;
7329 _parsingFunction = ParsingFunction.InIncrementalRead;
7330 }
7331
7332 private int IncrementalRead(Array array, int index, int count)
7333 {
7334 if (array == null)
7335 {
7336 throw new ArgumentNullException((_incReadDecoder is IncrementalReadCharsDecoder) ? "buffer" : "array");
7337 }
7338 if (count < 0)
7339 {
7341 }
7342 if (index < 0)
7343 {
7345 }
7346 if (array.Length - index < count)
7347 {
7348 throw new ArgumentException((_incReadDecoder is IncrementalReadCharsDecoder) ? "count" : "len");
7349 }
7350 if (count == 0)
7351 {
7352 return 0;
7353 }
7358 }
7359
7360 private int IncrementalRead()
7361 {
7362 int num = 0;
7363 int num3;
7364 while (true)
7365 {
7367 if (num2 > 0)
7368 {
7369 try
7370 {
7372 }
7373 catch (XmlException e)
7374 {
7376 return 0;
7377 }
7378 if (num3 < num2)
7379 {
7382 return num3;
7383 }
7388 {
7389 break;
7390 }
7391 }
7392 int outStartPos = 0;
7393 int outEndPos = 0;
7394 while (true)
7395 {
7396 switch (_incReadState)
7397 {
7398 case IncrementalReadState.PI:
7400 {
7401 _ps.charPos -= 2;
7403 }
7404 break;
7405 case IncrementalReadState.Comment:
7407 {
7408 _ps.charPos -= 3;
7410 }
7411 break;
7412 case IncrementalReadState.CDATA:
7414 {
7415 _ps.charPos -= 3;
7417 }
7418 break;
7419 case IncrementalReadState.EndElement:
7420 _parsingFunction = ParsingFunction.PopElementContext;
7421 _nextParsingFunction = ((_index <= 0 && _fragmentType == XmlNodeType.Document) ? ParsingFunction.DocumentContent : ParsingFunction.ElementContent);
7424 goto case IncrementalReadState.End;
7425 case IncrementalReadState.End:
7426 return num;
7427 case IncrementalReadState.ReadData:
7428 if (ReadData() == 0)
7429 {
7431 }
7435 goto default;
7436 default:
7437 {
7438 char[] chars = _ps.chars;
7441 while (true)
7442 {
7444 if (_incReadState == IncrementalReadState.Attributes)
7445 {
7446 char c;
7447 while (XmlCharType.IsAttributeValueChar(c = chars[outEndPos]) && c != '/')
7448 {
7449 outEndPos++;
7450 }
7451 }
7452 else
7453 {
7454 char c;
7456 {
7457 outEndPos++;
7458 }
7459 }
7460 if (chars[outEndPos] == '&' || chars[outEndPos] == '\t')
7461 {
7462 outEndPos++;
7463 continue;
7464 }
7465 if (outEndPos - outStartPos <= 0)
7466 {
7467 char c2 = chars[outEndPos];
7468 if ((uint)c2 <= 34u)
7469 {
7470 if (c2 == '\n')
7471 {
7472 outEndPos++;
7474 continue;
7475 }
7476 if (c2 == '\r')
7477 {
7478 if (chars[outEndPos + 1] == '\n')
7479 {
7480 outEndPos += 2;
7481 }
7482 else
7483 {
7484 if (outEndPos + 1 >= _ps.charsUsed)
7485 {
7486 goto IL_0662;
7487 }
7488 outEndPos++;
7489 }
7491 continue;
7492 }
7493 if (c2 == '"')
7494 {
7495 goto IL_0600;
7496 }
7497 }
7498 else if ((uint)c2 <= 47u)
7499 {
7500 if (c2 == '\'')
7501 {
7502 goto IL_0600;
7503 }
7504 if (c2 == '/')
7505 {
7506 if (_incReadState == IncrementalReadState.Attributes)
7507 {
7508 if (_ps.charsUsed - outEndPos < 2)
7509 {
7510 goto IL_0662;
7511 }
7512 if (chars[outEndPos + 1] == '>')
7513 {
7515 _incReadDepth--;
7516 }
7517 }
7518 outEndPos++;
7519 continue;
7520 }
7521 }
7522 else
7523 {
7524 if (c2 == '<')
7525 {
7526 if (_incReadState != 0)
7527 {
7528 outEndPos++;
7529 continue;
7530 }
7531 if (_ps.charsUsed - outEndPos < 2)
7532 {
7533 goto IL_0662;
7534 }
7535 char c3 = chars[outEndPos + 1];
7536 if (c3 != '!')
7537 {
7538 switch (c3)
7539 {
7540 case '?':
7541 outEndPos += 2;
7543 break;
7544 case '/':
7545 {
7546 int colonPos2;
7547 int num5 = ParseQName(isQName: true, 2, out colonPos2);
7549 {
7550 if (--_incReadDepth > 0)
7551 {
7552 outEndPos = num5 + 1;
7553 continue;
7554 }
7555 _ps.charPos = num5;
7557 {
7558 EatWhitespaces(null);
7559 }
7560 if (_ps.chars[_ps.charPos] != '>')
7561 {
7563 }
7564 goto end_IL_00bb;
7565 }
7566 outEndPos = num5;
7568 chars = _ps.chars;
7569 continue;
7570 }
7571 default:
7572 {
7573 int colonPos;
7574 int num4 = ParseQName(isQName: true, 1, out colonPos);
7576 {
7577 _incReadDepth++;
7579 outEndPos = num4;
7580 break;
7581 }
7582 outEndPos = num4;
7584 chars = _ps.chars;
7585 continue;
7586 }
7587 }
7588 }
7589 else
7590 {
7591 if (_ps.charsUsed - outEndPos < 4)
7592 {
7593 goto IL_0662;
7594 }
7595 if (chars[outEndPos + 2] == '-' && chars[outEndPos + 3] == '-')
7596 {
7597 outEndPos += 4;
7599 }
7600 else
7601 {
7602 if (_ps.charsUsed - outEndPos < 9)
7603 {
7604 goto IL_0662;
7605 }
7606 if (!XmlConvert.StrEqual(chars, outEndPos + 2, 7, "[CDATA["))
7607 {
7608 continue;
7609 }
7610 outEndPos += 9;
7612 }
7613 }
7614 goto IL_0669;
7615 }
7616 if (c2 == '>')
7617 {
7618 if (_incReadState == IncrementalReadState.Attributes)
7619 {
7621 }
7622 outEndPos++;
7623 continue;
7624 }
7625 }
7626 if (outEndPos != _ps.charsUsed)
7627 {
7628 outEndPos++;
7629 continue;
7630 }
7631 goto IL_0662;
7632 }
7633 goto IL_0669;
7634 IL_0669:
7636 break;
7637 IL_0662:
7639 goto IL_0669;
7640 IL_0600:
7641 switch (_incReadState)
7642 {
7643 case IncrementalReadState.AttributeValue:
7645 {
7647 }
7648 break;
7649 case IncrementalReadState.Attributes:
7651 _incReadState = IncrementalReadState.AttributeValue;
7652 break;
7653 }
7654 outEndPos++;
7655 }
7656 break;
7657 }
7658 }
7659 int num6 = outEndPos - outStartPos;
7660 if (num6 > 0)
7661 {
7662 int num7;
7663 try
7664 {
7666 }
7667 catch (XmlException e2)
7668 {
7670 return 0;
7671 }
7672 num += num7;
7674 {
7678 return num;
7679 }
7680 }
7681 continue;
7683 break;
7684 }
7685 _ps.charPos++;
7687 }
7688 return num3;
7689 }
7690
7692 {
7695 _incReadDecoder = null;
7696 }
7697
7699 {
7700 if (_curNode.type == XmlNodeType.None)
7701 {
7702 _curNode.type = XmlNodeType.Attribute;
7703 _curAttrIndex = 0;
7705 }
7706 else
7707 {
7708 _parsingFunction = ParsingFunction.InReadAttributeValue;
7709 }
7710 if (ReadAttributeValue())
7711 {
7712 _parsingFunction = ParsingFunction.FragmentAttribute;
7713 return true;
7714 }
7715 OnEof();
7716 return false;
7717 }
7718
7720 {
7721 char[] chars = _ps.chars;
7723 _curNode = AddNode(_index + _attrCount + 1, _index + 2);
7726 {
7727 _curNode.SetValueNode(XmlNodeType.Text, string.Empty);
7729 return true;
7730 }
7731 while (true)
7732 {
7734 {
7735 charRefEndPos++;
7736 continue;
7737 }
7738 switch (chars[charRefEndPos])
7739 {
7740 case '\r':
7741 charRefEndPos++;
7742 continue;
7743 case '\t':
7744 case '\n':
7745 if (_normalize)
7746 {
7747 chars[charRefEndPos] = ' ';
7748 }
7749 charRefEndPos++;
7750 continue;
7751 case '"':
7752 case '\'':
7753 case '>':
7754 charRefEndPos++;
7755 continue;
7756 case '<':
7758 goto IL_025f;
7759 case '&':
7760 {
7761 if (charRefEndPos - _ps.charPos > 0)
7762 {
7764 }
7767 if ((uint)entityType > 2u)
7768 {
7769 if (entityType == EntityType.Unexpanded)
7770 {
7771 if (_stringBuilder.Length == 0)
7772 {
7774 _ps.charPos++;
7776 return true;
7777 }
7778 break;
7779 }
7780 }
7781 else
7782 {
7783 chars = _ps.chars;
7785 {
7786 chars[_ps.charPos] = ' ';
7787 }
7788 }
7789 chars = _ps.chars;
7790 continue;
7791 }
7792 default:
7793 {
7795 {
7796 char ch = chars[charRefEndPos];
7798 {
7799 if (charRefEndPos + 1 == _ps.charsUsed)
7800 {
7801 goto IL_025f;
7802 }
7803 charRefEndPos++;
7805 {
7806 charRefEndPos++;
7807 continue;
7808 }
7809 }
7811 }
7812 goto IL_025f;
7813 }
7814 IL_025f:
7815 if (charRefEndPos - _ps.charPos > 0)
7816 {
7819 }
7820 if (ReadData() == 0)
7821 {
7822 if (_stringBuilder.Length > 0)
7823 {
7824 break;
7825 }
7827 {
7829 return true;
7830 }
7831 }
7833 chars = _ps.chars;
7834 continue;
7835 }
7836 break;
7837 }
7838 if (charRefEndPos - _ps.charPos > 0)
7839 {
7842 }
7845 return true;
7846 }
7847
7849 {
7850 try
7851 {
7853 }
7854 catch (XmlException ex)
7855 {
7856 ReThrow(ex, ex.LineNumber, ex.LinePosition - 6);
7857 }
7858 }
7859
7860 private void ThrowUnexpectedToken(int pos, string expectedToken)
7861 {
7863 }
7864
7866 {
7868 }
7869
7870 private void ThrowUnexpectedToken(int pos, string expectedToken1, string expectedToken2)
7871 {
7872 _ps.charPos = pos;
7874 }
7875
7877 {
7878 string text = ParseUnexpectedToken();
7879 if (text == null)
7880 {
7882 }
7883 if (expectedToken2 != null)
7884 {
7885 Throw(System.SR.Xml_UnexpectedTokens2, new string[3] { text, expectedToken1, expectedToken2 });
7886 }
7887 else
7888 {
7889 Throw(System.SR.Xml_UnexpectedTokenEx, new string[2] { text, expectedToken1 });
7890 }
7891 }
7892
7893 private string ParseUnexpectedToken(int pos)
7894 {
7895 _ps.charPos = pos;
7896 return ParseUnexpectedToken();
7897 }
7898
7899 private string ParseUnexpectedToken()
7900 {
7901 if (_ps.charPos == _ps.charsUsed)
7902 {
7903 return null;
7904 }
7906 {
7907 int i;
7908 for (i = _ps.charPos + 1; XmlCharType.IsNCNameSingleChar(_ps.chars[i]); i++)
7909 {
7910 }
7911 return new string(_ps.chars, _ps.charPos, i - _ps.charPos);
7912 }
7913 return new string(_ps.chars, _ps.charPos, 1);
7914 }
7915
7916 private void ThrowExpectingWhitespace(int pos)
7917 {
7918 string text = ParseUnexpectedToken(pos);
7919 if (text == null)
7920 {
7922 }
7923 else
7924 {
7926 }
7927 }
7928
7929 private int GetIndexOfAttributeWithoutPrefix(string name)
7930 {
7931 string text = _nameTable.Get(name);
7932 if (text == null)
7933 {
7934 return -1;
7935 }
7936 for (int i = _index + 1; i < _index + _attrCount + 1; i++)
7937 {
7938 if (Ref.Equal(_nodes[i].localName, text) && _nodes[i].prefix.Length == 0)
7939 {
7940 return i;
7941 }
7942 }
7943 return -1;
7944 }
7945
7946 private int GetIndexOfAttributeWithPrefix(string name)
7947 {
7948 name = _nameTable.Add(name);
7949 if (name == null)
7950 {
7951 return -1;
7952 }
7953 for (int i = _index + 1; i < _index + _attrCount + 1; i++)
7954 {
7955 if (Ref.Equal(_nodes[i].GetNameWPrefix(_nameTable), name))
7956 {
7957 return i;
7958 }
7959 }
7960 return -1;
7961 }
7962
7963 private bool ZeroEndingStream(int pos)
7964 {
7965 if (_v1Compat && pos == _ps.charsUsed - 1 && _ps.chars[pos] == '\0' && ReadData() == 0 && _ps.isStreamEof)
7966 {
7967 _ps.charsUsed--;
7968 return true;
7969 }
7970 return false;
7971 }
7972
7982
7984 {
7985 if (_parsingFunction == ParsingFunction.InReadValueChunk)
7986 {
7988 }
7989 if (_parsingFunction == ParsingFunction.InIncrementalRead)
7990 {
7992 }
7994 {
7995 return false;
7996 }
7997 SetupReadContentAsBinaryState(ParsingFunction.InReadContentAsBinary);
7999 return true;
8000 }
8001
8003 {
8006 if (isEmptyElement)
8007 {
8008 return false;
8009 }
8011 {
8012 if (_curNode.type != XmlNodeType.EndElement)
8013 {
8015 }
8017 return false;
8018 }
8019 SetupReadContentAsBinaryState(ParsingFunction.InReadElementContentAsBinary);
8021 return true;
8022 }
8023
8025 {
8026 do
8027 {
8028 switch (_curNode.type)
8029 {
8030 case XmlNodeType.Attribute:
8031 return !moveIfOnContentNode;
8032 case XmlNodeType.Text:
8033 case XmlNodeType.CDATA:
8034 case XmlNodeType.Whitespace:
8035 case XmlNodeType.SignificantWhitespace:
8037 {
8038 return true;
8039 }
8040 break;
8041 case XmlNodeType.EntityReference:
8043 break;
8044 default:
8045 return false;
8046 case XmlNodeType.ProcessingInstruction:
8047 case XmlNodeType.Comment:
8048 case XmlNodeType.EndEntity:
8049 break;
8050 }
8051 moveIfOnContentNode = false;
8052 }
8053 while (_outerReader.Read());
8054 return false;
8055 }
8056
8058 {
8059 if (_parsingFunction == ParsingFunction.PartialTextValue)
8060 {
8061 _incReadState = IncrementalReadState.ReadContentAsBinary_OnPartialValue;
8062 }
8063 else
8064 {
8065 _incReadState = IncrementalReadState.ReadContentAsBinary_OnCachedValue;
8068 }
8069 _readValueOffset = 0;
8071 }
8072
8073 [MemberNotNull("_nameTable")]
8075 {
8078 if (context.NamespaceManager != null)
8079 {
8080 if (xmlNameTable != null && xmlNameTable != context.NamespaceManager.NameTable)
8081 {
8083 }
8087 }
8088 else if (context.NameTable != null)
8089 {
8090 if (xmlNameTable != null && xmlNameTable != context.NameTable)
8091 {
8092 throw new XmlException(System.SR.Xml_NametableMismatch, string.Empty);
8093 }
8094 xmlNameTable = context.NameTable;
8095 }
8096 else if (xmlNameTable == null)
8097 {
8098 xmlNameTable = new NameTable();
8099 }
8101 if (_namespaceManager == null)
8102 {
8104 }
8106 _xmlContext.xmlLang = context.XmlLang;
8107 }
8108
8117
8122
8124 {
8125 if (IsResolverNull)
8126 {
8127 return null;
8128 }
8129 return _xmlResolver;
8130 }
8131
8133 {
8134 if (defAttrInfo.Prefix.Length > 0)
8135 {
8137 }
8138 string localName = defAttrInfo.LocalName;
8139 string prefix = defAttrInfo.Prefix;
8140 if (nameSortedNodeData != null)
8141 {
8143 {
8144 return false;
8145 }
8146 }
8147 else
8148 {
8149 for (int i = _index + 1; i < _index + 1 + _attrCount; i++)
8150 {
8151 if ((object)_nodes[i].localName == localName && (object)_nodes[i].prefix == prefix)
8152 {
8153 return false;
8154 }
8155 }
8156 }
8157 NodeData nodeData = AddDefaultAttributeInternal(defAttrInfo.LocalName, null, defAttrInfo.Prefix, defAttrInfo.DefaultValueExpanded, defAttrInfo.LineNumber, defAttrInfo.LinePosition, defAttrInfo.ValueLineNumber, defAttrInfo.ValueLinePosition, defAttrInfo.IsXmlAttribute);
8158 if (DtdValidation)
8159 {
8160 if (_onDefaultAttributeUse != null)
8161 {
8163 }
8164 nodeData.typedValue = defAttrInfo.DefaultValueTyped;
8165 }
8166 return nodeData != null;
8167 }
8168
8170 {
8171 string text = _nameTable.Add(attrDef.Name.Name);
8172 string text2 = _nameTable.Add(attrDef.Prefix);
8173 string text3 = _nameTable.Add(attrDef.Name.Namespace);
8174 if (text2.Length == 0 && text3.Length > 0)
8175 {
8177 if (text2 == null)
8178 {
8179 text2 = string.Empty;
8180 }
8181 }
8182 for (int i = _index + 1; i < _index + 1 + _attrCount; i++)
8183 {
8184 if ((object)_nodes[i].localName == text && ((object)_nodes[i].prefix == text2 || ((object)_nodes[i].ns == text3 && text3 != null)))
8185 {
8186 return false;
8187 }
8188 }
8189 NodeData nodeData = AddDefaultAttributeInternal(text, text3, text2, attrDef.DefaultValueExpanded, attrDef.LineNumber, attrDef.LinePosition, attrDef.ValueLineNumber, attrDef.ValueLinePosition, attrDef.Reserved != SchemaAttDef.Reserve.None);
8190 nodeData.schemaType = ((attrDef.SchemaType == null) ? ((object)attrDef.Datatype) : ((object)attrDef.SchemaType));
8191 nodeData.typedValue = attrDef.DefaultValueTyped;
8192 return true;
8193 }
8194
8195 private NodeData AddDefaultAttributeInternal(string localName, string ns, string prefix, string value, int lineNo, int linePos, int valueLineNo, int valueLinePos, bool isXmlAttribute)
8196 {
8197 NodeData nodeData = AddAttribute(localName, prefix, (prefix.Length > 0) ? null : localName);
8198 if (ns != null)
8199 {
8200 nodeData.ns = ns;
8201 }
8202 nodeData.SetValue(value);
8204 nodeData.lineInfo.Set(lineNo, linePos);
8205 nodeData.lineInfo2.Set(valueLineNo, valueLinePos);
8206 if (nodeData.prefix.Length == 0)
8207 {
8208 if (Ref.Equal(nodeData.localName, _xmlNs))
8209 {
8211 if (!_attrNeedNamespaceLookup && _nodes[_index].prefix.Length == 0)
8212 {
8214 }
8215 }
8216 }
8217 else if (Ref.Equal(nodeData.prefix, _xmlNs))
8218 {
8221 {
8222 string localName2 = nodeData.localName;
8223 for (int i = _index; i < _index + _attrCount + 1; i++)
8224 {
8225 if (_nodes[i].prefix.Equals(localName2))
8226 {
8228 }
8229 }
8230 }
8231 }
8232 else if (isXmlAttribute)
8233 {
8235 }
8236 _fullAttrCleanup = true;
8237 return nodeData;
8238 }
8239
8240 private int ReadContentAsBinary(byte[] buffer, int index, int count)
8241 {
8242 if (_incReadState == IncrementalReadState.ReadContentAsBinary_End)
8243 {
8244 return 0;
8245 }
8248 while (true)
8249 {
8250 int num = 0;
8251 try
8252 {
8254 }
8255 catch (XmlException e)
8256 {
8259 }
8260 _readValueOffset += num;
8262 {
8264 }
8265 if (_incReadState == IncrementalReadState.ReadContentAsBinary_OnPartialValue)
8266 {
8267 _curNode.SetValue(string.Empty);
8268 bool flag = false;
8269 int startPos = 0;
8270 int endPos = 0;
8271 while (!_incReadDecoder.IsFull && !flag)
8272 {
8273 int outOrChars = 0;
8275 flag = ParseText(out startPos, out endPos, ref outOrChars);
8276 try
8277 {
8279 }
8280 catch (XmlException e2)
8281 {
8283 }
8284 startPos += num;
8285 }
8287 _readValueOffset = 0;
8289 {
8294 }
8295 }
8300 {
8301 break;
8302 }
8305 }
8307 _incReadState = IncrementalReadState.ReadContentAsBinary_End;
8309 }
8310
8311 private int ReadElementContentAsBinary(byte[] buffer, int index, int count)
8312 {
8313 if (count == 0)
8314 {
8315 return 0;
8316 }
8318 if (num > 0)
8319 {
8320 return num;
8321 }
8322 if (_curNode.type != XmlNodeType.EndElement)
8323 {
8324 throw new XmlException(System.SR.Xml_InvalidNodeType, _curNode.type.ToString(), this);
8325 }
8329 return 0;
8330 }
8331
8332 private void InitBase64Decoder()
8333 {
8334 if (_base64Decoder == null)
8335 {
8337 }
8338 else
8339 {
8341 }
8343 }
8344
8345 private void InitBinHexDecoder()
8346 {
8347 if (_binHexDecoder == null)
8348 {
8350 }
8351 else
8352 {
8354 }
8356 }
8357
8358 private bool UriEqual(Uri uri1, string uri1Str, string uri2Str, XmlResolver resolver)
8359 {
8360 if (resolver == null)
8361 {
8362 return uri1Str == uri2Str;
8363 }
8364 if (uri1 == null)
8365 {
8366 uri1 = resolver.ResolveUri(null, uri1Str);
8367 }
8368 Uri obj = resolver.ResolveUri(null, uri2Str);
8369 return uri1.Equals(obj);
8370 }
8371
8372 private void RegisterConsumedCharacters(long characters, bool inEntityReference)
8373 {
8375 {
8376 long num = _charactersInDocument + characters;
8377 if (num < _charactersInDocument)
8378 {
8379 ThrowWithoutLineInfo(System.SR.Xml_LimitExceeded, "MaxCharactersInDocument");
8380 }
8381 else
8382 {
8384 }
8386 {
8387 ThrowWithoutLineInfo(System.SR.Xml_LimitExceeded, "MaxCharactersInDocument");
8388 }
8389 }
8391 {
8392 long num2 = _charactersFromEntities + characters;
8394 {
8395 ThrowWithoutLineInfo(System.SR.Xml_LimitExceeded, "MaxCharactersFromEntities");
8396 }
8397 else
8398 {
8400 }
8402 {
8403 ThrowWithoutLineInfo(System.SR.Xml_LimitExceeded, "MaxCharactersFromEntities");
8404 }
8405 }
8406 }
8407
8408 internal static void AdjustLineInfo(char[] chars, int startPos, int endPos, bool isNormalized, ref LineInfo lineInfo)
8409 {
8411 }
8412
8413 internal static void AdjustLineInfo(string str, int startPos, int endPos, bool isNormalized, ref LineInfo lineInfo)
8414 {
8415 AdjustLineInfo(str.AsSpan(startPos, endPos - startPos), isNormalized, ref lineInfo);
8416 }
8417
8419 {
8420 int num = -1;
8421 for (int i = 0; i < chars.Length; i++)
8422 {
8423 switch (chars[i])
8424 {
8425 case '\n':
8426 lineInfo.lineNo++;
8427 num = i;
8428 break;
8429 case '\r':
8430 if (!isNormalized)
8431 {
8432 lineInfo.lineNo++;
8433 num = i;
8434 int num2 = i + 1;
8435 if ((uint)num2 < (uint)chars.Length && chars[num2] == '\n')
8436 {
8437 i++;
8438 num++;
8439 }
8440 }
8441 break;
8442 }
8443 }
8444 if (num >= 0)
8445 {
8447 }
8448 }
8449
8450 internal static string StripSpaces(string value)
8451 {
8452 int length = value.Length;
8453 if (length <= 0)
8454 {
8455 return string.Empty;
8456 }
8457 int num = 0;
8459 while (value[num] == ' ')
8460 {
8461 num++;
8462 if (num == length)
8463 {
8464 return " ";
8465 }
8466 }
8467 int i;
8468 for (i = num; i < length; i++)
8469 {
8470 if (value[i] != ' ')
8471 {
8472 continue;
8473 }
8474 int j;
8475 for (j = i + 1; j < length && value[j] == ' '; j++)
8476 {
8477 }
8478 if (j == length)
8479 {
8480 if (stringBuilder == null)
8481 {
8482 return value.Substring(num, i - num);
8483 }
8484 stringBuilder.Append(value, num, i - num);
8485 return stringBuilder.ToString();
8486 }
8487 if (j > i + 1)
8488 {
8489 if (stringBuilder == null)
8490 {
8492 }
8493 stringBuilder.Append(value, num, i - num + 1);
8494 num = j;
8495 i = j - 1;
8496 }
8497 }
8498 if (stringBuilder == null)
8499 {
8500 if (num != 0)
8501 {
8502 return value.Substring(num, length - num);
8503 }
8504 return value;
8505 }
8506 if (i > num)
8507 {
8508 stringBuilder.Append(value, num, i - num);
8509 }
8510 return stringBuilder.ToString();
8511 }
8512
8513 internal static void StripSpaces(char[] value, int index, ref int len)
8514 {
8515 if (len <= 0)
8516 {
8517 return;
8518 }
8519 int num = index;
8520 int num2 = index + len;
8521 while (value[num] == ' ')
8522 {
8523 num++;
8524 if (num == num2)
8525 {
8526 len = 1;
8527 return;
8528 }
8529 }
8530 int num3 = num - index;
8531 for (int i = num; i < num2; i++)
8532 {
8533 char c;
8534 if ((c = value[i]) == ' ')
8535 {
8536 int j;
8537 for (j = i + 1; j < num2 && value[j] == ' '; j++)
8538 {
8539 }
8540 if (j == num2)
8541 {
8542 num3 += j - i;
8543 break;
8544 }
8545 if (j > i + 1)
8546 {
8547 num3 += j - i - 1;
8548 i = j - 1;
8549 }
8550 }
8551 value[i - num3] = c;
8552 }
8553 len -= num3;
8554 }
8555
8556 internal static void BlockCopyChars(char[] src, int srcOffset, char[] dst, int dstOffset, int count)
8557 {
8558 Buffer.BlockCopy(src, srcOffset * 2, dst, dstOffset * 2, count * 2);
8559 }
8560
8561 internal static void BlockCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
8562 {
8564 }
8565
8566 private void CheckAsyncCall()
8567 {
8568 if (!_useAsync)
8569 {
8571 }
8572 }
8573
8574 public override Task<string> GetValueAsync()
8575 {
8577 if (_parsingFunction >= ParsingFunction.PartialTextValue)
8578 {
8579 return _GetValueAsync();
8580 }
8581 return Task.FromResult(_curNode.StringValue);
8582 }
8583
8585 {
8586 if (_parsingFunction >= ParsingFunction.PartialTextValue)
8587 {
8588 if (_parsingFunction != ParsingFunction.PartialTextValue)
8589 {
8591 }
8592 else
8593 {
8596 }
8597 }
8598 return _curNode.StringValue;
8599 }
8600
8611
8613 {
8615 if (stream == null)
8616 {
8618 }
8619 Encoding encoding = null;
8620 if (_laterInitParam.inputContext != null)
8621 {
8623 }
8624 try
8625 {
8629 {
8631 }
8632 }
8633 catch
8634 {
8635 stream.Dispose();
8636 throw;
8637 }
8638 _laterInitParam = null;
8639 }
8640
8656
8667
8668 public override Task<bool> ReadAsync()
8669 {
8671 if (_laterInitParam != null)
8672 {
8673 return FinishInitAsync().CallBoolTaskFuncWhenFinishAsync((XmlTextReaderImpl thisRef) => thisRef.ReadAsync(), this);
8674 }
8675 while (true)
8676 {
8677 switch (_parsingFunction)
8678 {
8679 case ParsingFunction.ElementContent:
8680 return ParseElementContentAsync();
8681 case ParsingFunction.DocumentContent:
8683 case ParsingFunction.SwitchToInteractive:
8684 _readState = ReadState.Interactive;
8686 break;
8687 case ParsingFunction.SwitchToInteractiveXmlDecl:
8689 case ParsingFunction.ResetAttributesRootLevel:
8692 _parsingFunction = ((_index == 0) ? ParsingFunction.DocumentContent : ParsingFunction.ElementContent);
8693 break;
8694 case ParsingFunction.MoveToElementContent:
8696 _index++;
8698 _parsingFunction = ParsingFunction.ElementContent;
8699 break;
8700 case ParsingFunction.PopElementContext:
8703 break;
8704 case ParsingFunction.PopEmptyElementContext:
8710 break;
8711 case ParsingFunction.EntityReference:
8713 return ParseEntityReferenceAsync().ReturnTrueTaskWhenFinishAsync();
8714 case ParsingFunction.ReportEndEntity:
8718 case ParsingFunction.AfterResolveEntityInContent:
8723 break;
8724 case ParsingFunction.AfterResolveEmptyEntityInContent:
8726 _curNode.SetValueNode(XmlNodeType.Text, string.Empty);
8732 case ParsingFunction.InReadAttributeValue:
8735 break;
8736 case ParsingFunction.InIncrementalRead:
8739 case ParsingFunction.FragmentAttribute:
8740 return Task.FromResult(ParseFragmentAttribute());
8741 case ParsingFunction.XmlDeclarationFragment:
8745 case ParsingFunction.GoToEof:
8746 OnEof();
8748 case ParsingFunction.Error:
8749 case ParsingFunction.Eof:
8750 case ParsingFunction.ReaderClosed:
8752 case ParsingFunction.NoData:
8755 case ParsingFunction.PartialTextValue:
8756 return SkipPartialTextValueAsync().CallBoolTaskFuncWhenFinishAsync((XmlTextReaderImpl thisRef) => thisRef.ReadAsync(), this);
8757 case ParsingFunction.InReadValueChunk:
8758 return FinishReadValueChunkAsync().CallBoolTaskFuncWhenFinishAsync((XmlTextReaderImpl thisRef) => thisRef.ReadAsync(), this);
8759 case ParsingFunction.InReadContentAsBinary:
8760 return FinishReadContentAsBinaryAsync().CallBoolTaskFuncWhenFinishAsync((XmlTextReaderImpl thisRef) => thisRef.ReadAsync(), this);
8761 case ParsingFunction.InReadElementContentAsBinary:
8762 return FinishReadElementContentAsBinaryAsync().CallBoolTaskFuncWhenFinishAsync((XmlTextReaderImpl thisRef) => thisRef.ReadAsync(), this);
8763 }
8764 }
8765 }
8766
8778
8783
8785 {
8786 if (finish)
8787 {
8790 }
8792 return ReadAsync();
8793 }
8794
8795 public override async Task SkipAsync()
8796 {
8798 if (_readState != ReadState.Interactive)
8799 {
8800 return;
8801 }
8803 {
8806 }
8807 else
8808 {
8809 switch (_parsingFunction)
8810 {
8811 case ParsingFunction.InIncrementalRead:
8813 break;
8814 case ParsingFunction.PartialTextValue:
8816 break;
8817 case ParsingFunction.InReadValueChunk:
8819 break;
8820 case ParsingFunction.InReadContentAsBinary:
8822 break;
8823 case ParsingFunction.InReadElementContentAsBinary:
8825 break;
8826 }
8827 }
8829 if (type != XmlNodeType.Element)
8830 {
8831 if (type != XmlNodeType.Attribute)
8832 {
8833 goto IL_0328;
8834 }
8836 }
8838 {
8839 int initialDepth = _index;
8840 _parsingMode = ParsingMode.SkipContent;
8841 while (await _outerReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false) && _index > initialDepth)
8842 {
8843 }
8845 }
8846 goto IL_0328;
8847 IL_0328:
8848 await _outerReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
8849 }
8850
8852 {
8853 if (!(await task.ConfigureAwait(continueOnCapturedContext: false)))
8854 {
8855 return 0;
8856 }
8859 }
8860
8861 public override Task<int> ReadContentAsBase64Async(byte[] buffer, int index, int count)
8862 {
8864 if (buffer == null)
8865 {
8866 throw new ArgumentNullException("buffer");
8867 }
8868 if (count < 0)
8869 {
8870 throw new ArgumentOutOfRangeException("count");
8871 }
8872 if (index < 0)
8873 {
8874 throw new ArgumentOutOfRangeException("index");
8875 }
8876 if (buffer.Length - index < count)
8877 {
8878 throw new ArgumentOutOfRangeException("count");
8879 }
8880 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
8881 {
8883 {
8885 }
8886 }
8887 else
8888 {
8889 if (_readState != ReadState.Interactive)
8890 {
8892 }
8893 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
8894 {
8896 }
8898 {
8899 throw CreateReadContentAsException("ReadContentAsBase64");
8900 }
8902 if (!task.IsSuccess())
8903 {
8905 }
8906 if (!task.Result)
8907 {
8909 }
8910 }
8913 }
8914
8915 public override async Task<int> ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
8916 {
8918 if (buffer == null)
8919 {
8920 throw new ArgumentNullException("buffer");
8921 }
8922 if (count < 0)
8923 {
8924 throw new ArgumentOutOfRangeException("count");
8925 }
8926 if (index < 0)
8927 {
8928 throw new ArgumentOutOfRangeException("index");
8929 }
8930 if (buffer.Length - index < count)
8931 {
8932 throw new ArgumentOutOfRangeException("count");
8933 }
8934 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
8935 {
8937 {
8939 }
8940 }
8941 else
8942 {
8943 if (_readState != ReadState.Interactive)
8944 {
8945 return 0;
8946 }
8947 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
8948 {
8950 }
8952 {
8953 throw CreateReadContentAsException("ReadContentAsBinHex");
8954 }
8955 if (!(await InitReadContentAsBinaryAsync().ConfigureAwait(continueOnCapturedContext: false)))
8956 {
8957 return 0;
8958 }
8959 }
8962 }
8963
8965 {
8966 if (!(await task.ConfigureAwait(continueOnCapturedContext: false)))
8967 {
8968 return 0;
8969 }
8972 }
8973
8975 {
8977 if (buffer == null)
8978 {
8979 throw new ArgumentNullException("buffer");
8980 }
8981 if (count < 0)
8982 {
8983 throw new ArgumentOutOfRangeException("count");
8984 }
8985 if (index < 0)
8986 {
8987 throw new ArgumentOutOfRangeException("index");
8988 }
8989 if (buffer.Length - index < count)
8990 {
8991 throw new ArgumentOutOfRangeException("count");
8992 }
8993 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
8994 {
8996 {
8998 }
8999 }
9000 else
9001 {
9002 if (_readState != ReadState.Interactive)
9003 {
9005 }
9006 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
9007 {
9009 }
9010 if (_curNode.type != XmlNodeType.Element)
9011 {
9012 throw CreateReadElementContentAsException("ReadElementContentAsBinHex");
9013 }
9015 if (!task.IsSuccess())
9016 {
9018 }
9019 if (!task.Result)
9020 {
9022 }
9023 }
9026 }
9027
9029 {
9031 if (buffer == null)
9032 {
9033 throw new ArgumentNullException("buffer");
9034 }
9035 if (count < 0)
9036 {
9037 throw new ArgumentOutOfRangeException("count");
9038 }
9039 if (index < 0)
9040 {
9041 throw new ArgumentOutOfRangeException("index");
9042 }
9043 if (buffer.Length - index < count)
9044 {
9045 throw new ArgumentOutOfRangeException("count");
9046 }
9047 if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
9048 {
9050 {
9052 }
9053 }
9054 else
9055 {
9056 if (_readState != ReadState.Interactive)
9057 {
9058 return 0;
9059 }
9060 if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
9061 {
9063 }
9064 if (_curNode.type != XmlNodeType.Element)
9065 {
9066 throw CreateReadElementContentAsException("ReadElementContentAsBinHex");
9067 }
9069 {
9070 return 0;
9071 }
9072 }
9075 }
9076
9077 public override async Task<int> ReadValueChunkAsync(char[] buffer, int index, int count)
9078 {
9081 {
9083 }
9084 if (buffer == null)
9085 {
9086 throw new ArgumentNullException("buffer");
9087 }
9088 if (count < 0)
9089 {
9090 throw new ArgumentOutOfRangeException("count");
9091 }
9092 if (index < 0)
9093 {
9094 throw new ArgumentOutOfRangeException("index");
9095 }
9096 if (buffer.Length - index < count)
9097 {
9098 throw new ArgumentOutOfRangeException("count");
9099 }
9100 if (_parsingFunction != ParsingFunction.InReadValueChunk)
9101 {
9102 if (_readState != ReadState.Interactive)
9103 {
9104 return 0;
9105 }
9106 if (_parsingFunction == ParsingFunction.PartialTextValue)
9107 {
9108 _incReadState = IncrementalReadState.ReadValueChunk_OnPartialValue;
9109 }
9110 else
9111 {
9112 _incReadState = IncrementalReadState.ReadValueChunk_OnCachedValue;
9115 }
9116 _parsingFunction = ParsingFunction.InReadValueChunk;
9117 _readValueOffset = 0;
9118 }
9119 if (count == 0)
9120 {
9121 return 0;
9122 }
9123 int readCount2 = 0;
9125 readCount2 += num;
9126 _readValueOffset += num;
9127 if (readCount2 == count)
9128 {
9129 char ch = buffer[index + count - 1];
9131 {
9132 readCount2--;
9134 if (readCount2 == 0)
9135 {
9137 }
9138 }
9139 return readCount2;
9140 }
9141 if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue)
9142 {
9143 _curNode.SetValue(string.Empty);
9144 bool flag = false;
9145 int num2 = 0;
9146 int num3 = 0;
9147 while (readCount2 < count && !flag)
9148 {
9149 int outOrChars = 0;
9151 (num2, num3, _, _) = tuple;
9152 _ = tuple.Item3;
9153 flag = tuple.Item4;
9154 int num4 = count - readCount2;
9155 if (num4 > num3 - num2)
9156 {
9157 num4 = num3 - num2;
9158 }
9160 readCount2 += num4;
9161 num2 += num4;
9162 }
9164 if (readCount2 == count)
9165 {
9166 char ch2 = buffer[index + count - 1];
9168 {
9169 readCount2--;
9170 num2--;
9171 if (readCount2 == 0)
9172 {
9174 }
9175 }
9176 }
9177 _readValueOffset = 0;
9179 }
9180 return readCount2;
9181 }
9182
9184 {
9186 return ReadDataAsync();
9187 }
9188
9194
9200
9202 {
9204 if (sb == null)
9205 {
9207 _parsingMode = ParsingMode.SkipNode;
9209 _parsingMode = pm;
9210 }
9211 else
9212 {
9214 }
9215 }
9216
9218 {
9220 try
9221 {
9222 if (sb == null)
9223 {
9225 _parsingMode = ParsingMode.SkipNode;
9228 }
9229 else
9230 {
9234 _curNode.CopyTo(0, sb);
9236 }
9237 }
9238 catch (XmlException ex)
9239 {
9240 if (ex.ResString == System.SR.Xml_UnexpectedEOF && _ps.entity != null)
9241 {
9243 return;
9244 }
9245 throw;
9246 }
9247 }
9248
9250 {
9252 bool item2;
9253 int item;
9254 if (entity.IsExternal)
9255 {
9256 if (IsResolverNull)
9257 {
9258 item = -1;
9259 return (item, false);
9260 }
9261 item2 = await PushExternalEntityAsync(entity).ConfigureAwait(continueOnCapturedContext: false);
9262 }
9263 else
9264 {
9265 PushInternalEntity(entity);
9266 item2 = true;
9267 }
9268 item = _ps.entityId;
9269 return (item, item2);
9270 }
9271
9272 internal async Task<bool> DtdParserProxy_PushExternalSubsetAsync(string systemId, string publicId)
9273 {
9275 if (IsResolverNull)
9276 {
9277 return false;
9278 }
9279 if (_ps.baseUri == null && !string.IsNullOrEmpty(_ps.baseUriStr))
9280 {
9282 }
9283 await PushExternalEntityOrSubsetAsync(publicId, systemId, _ps.baseUri, null).ConfigureAwait(continueOnCapturedContext: false);
9284 _ps.entity = null;
9285 _ps.entityId = 0;
9286 int initialPos = _ps.charPos;
9287 if (_v1Compat)
9288 {
9289 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
9290 }
9291 if (!(await ParseXmlDeclarationAsync(isTextDecl: true).ConfigureAwait(continueOnCapturedContext: false)))
9292 {
9294 }
9295 return true;
9296 }
9297
9299 {
9300 return InitStreamInputAsync(baseUri, baseUri.ToString(), stream, null, 0, encoding);
9301 }
9302
9303 private async Task InitStreamInputAsync(Uri baseUri, string baseUriStr, Stream stream, byte[] bytes, int byteCount, Encoding encoding)
9304 {
9306 _ps.baseUri = baseUri;
9307 _ps.baseUriStr = baseUriStr;
9308 int num;
9309 if (bytes != null)
9310 {
9311 _ps.bytes = bytes;
9313 num = _ps.bytes.Length;
9314 }
9315 else
9316 {
9317 num = ((_laterInitParam == null || !_laterInitParam.useAsync) ? XmlReader.CalcBufferSize(stream) : 65536);
9318 if (_ps.bytes == null || _ps.bytes.Length < num)
9319 {
9320 _ps.bytes = new byte[num];
9321 }
9322 }
9323 if (_ps.chars == null || _ps.chars.Length < num + 1)
9324 {
9325 _ps.chars = new char[num + 1];
9326 }
9327 _ps.bytePos = 0;
9328 while (_ps.bytesUsed < 4 && _ps.bytes.Length - _ps.bytesUsed > 0)
9329 {
9330 int num2 = await stream.ReadAsync(_ps.bytes.AsMemory(_ps.bytesUsed)).ConfigureAwait(continueOnCapturedContext: false);
9331 if (num2 == 0)
9332 {
9333 _ps.isStreamEof = true;
9334 break;
9335 }
9337 }
9338 if (encoding == null)
9339 {
9340 encoding = DetectEncoding();
9341 }
9342 SetupEncoding(encoding);
9343 EatPreamble();
9346 _ps.appendMode = true;
9347 await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false);
9348 }
9349
9350 private Task InitTextReaderInputAsync(string baseUriStr, TextReader input)
9351 {
9352 return InitTextReaderInputAsync(baseUriStr, null, input);
9353 }
9354
9355 private Task InitTextReaderInputAsync(string baseUriStr, Uri baseUri, TextReader input)
9356 {
9358 _ps.baseUriStr = baseUriStr;
9359 _ps.baseUri = baseUri;
9360 if (_ps.chars == null)
9361 {
9362 int num = ((_laterInitParam == null || !_laterInitParam.useAsync) ? 4096 : 65536);
9363 _ps.chars = new char[num + 1];
9364 }
9367 _ps.appendMode = true;
9368 return ReadDataAsync();
9369 }
9370
9372 {
9373 switch (_dtdProcessing)
9374 {
9375 case DtdProcessing.Prohibit:
9377 break;
9378 case DtdProcessing.Parse:
9380 }
9381 return Task.CompletedTask;
9382 }
9383
9385 {
9387 {
9388 UnDecodeChars();
9389 _ps.appendMode = false;
9391 return ReadDataAsync();
9392 }
9393 return Task.CompletedTask;
9394 }
9395
9400
9402 {
9403 if (_ps.isEof)
9404 {
9405 return 0;
9406 }
9407 int charsRead;
9408 if (_ps.appendMode)
9409 {
9410 if (_ps.charsUsed == _ps.chars.Length - 1)
9411 {
9412 for (int i = 0; i < _attrCount; i++)
9413 {
9415 }
9416 char[] array = new char[_ps.chars.Length * 2];
9417 BlockCopyChars(_ps.chars, 0, array, 0, _ps.chars.Length);
9418 _ps.chars = array;
9419 }
9420 if (_ps.stream != null && _ps.bytesUsed - _ps.bytePos < 6 && _ps.bytes.Length - _ps.bytesUsed < 6)
9421 {
9422 byte[] array2 = new byte[_ps.bytes.Length * 2];
9424 _ps.bytes = array2;
9425 }
9427 if (charsRead > 80)
9428 {
9429 charsRead = 80;
9430 }
9431 }
9432 else
9433 {
9434 int num = _ps.chars.Length;
9435 if (num - _ps.charsUsed <= num / 2)
9436 {
9437 for (int j = 0; j < _attrCount; j++)
9438 {
9440 }
9441 int num2 = _ps.charsUsed - _ps.charPos;
9442 if (num2 < num - 1)
9443 {
9445 if (num2 > 0)
9446 {
9448 }
9449 _ps.charPos = 0;
9451 }
9452 else
9453 {
9454 char[] array3 = new char[_ps.chars.Length * 2];
9455 BlockCopyChars(_ps.chars, 0, array3, 0, _ps.chars.Length);
9456 _ps.chars = array3;
9457 }
9458 }
9459 if (_ps.stream != null)
9460 {
9461 int num3 = _ps.bytesUsed - _ps.bytePos;
9462 if (num3 <= 128)
9463 {
9464 if (num3 == 0)
9465 {
9466 _ps.bytesUsed = 0;
9467 }
9468 else
9469 {
9472 }
9473 _ps.bytePos = 0;
9474 }
9475 }
9477 }
9478 if (_ps.stream != null)
9479 {
9480 if (!_ps.isStreamEof && _ps.bytePos == _ps.bytesUsed && _ps.bytes.Length - _ps.bytesUsed > 0)
9481 {
9483 if (num4 == 0)
9484 {
9485 _ps.isStreamEof = true;
9486 }
9488 }
9489 int bytePos = _ps.bytePos;
9491 if (charsRead == 0 && _ps.bytePos != bytePos)
9492 {
9493 return await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false);
9494 }
9495 }
9496 else if (_ps.textReader != null)
9497 {
9498 charsRead = await _ps.textReader.ReadAsync(_ps.chars.AsMemory(_ps.charsUsed, _ps.chars.Length - _ps.charsUsed - 1)).ConfigureAwait(continueOnCapturedContext: false);
9500 }
9501 else
9502 {
9503 charsRead = 0;
9504 }
9506 if (charsRead == 0)
9507 {
9508 _ps.isEof = true;
9509 }
9510 _ps.chars[_ps.charsUsed] = '\0';
9511 return charsRead;
9512 }
9513
9515 {
9516 do
9517 {
9518 if (_ps.charsUsed - _ps.charPos < 6)
9519 {
9520 continue;
9521 }
9523 {
9524 break;
9525 }
9526 if (!isTextDecl)
9527 {
9529 _curNode.SetNamedNode(XmlNodeType.XmlDeclaration, _xml);
9530 }
9531 _ps.charPos += 5;
9533 int xmlDeclState = 0;
9534 Encoding encoding = null;
9535 while (true)
9536 {
9537 int originalSbLen = sb.Length;
9538 int num = await EatWhitespacesAsync((xmlDeclState == 0) ? null : sb).ConfigureAwait(continueOnCapturedContext: false);
9539 if (_ps.chars[_ps.charPos] == '?')
9540 {
9542 if (_ps.chars[_ps.charPos + 1] == '>')
9543 {
9544 break;
9545 }
9546 if (_ps.charPos + 1 == _ps.charsUsed)
9547 {
9548 goto IL_0cb2;
9549 }
9550 ThrowUnexpectedToken("'>'");
9551 }
9552 if (num == 0 && xmlDeclState != 0)
9553 {
9555 }
9556 int num2 = await ParseNameAsync().ConfigureAwait(continueOnCapturedContext: false);
9557 NodeData attr = null;
9558 char c = _ps.chars[_ps.charPos];
9559 if (c != 'e')
9560 {
9561 if (c != 's')
9562 {
9563 if (c != 'v' || !XmlConvert.StrEqual(_ps.chars, _ps.charPos, num2 - _ps.charPos, "version") || xmlDeclState != 0)
9564 {
9565 goto IL_06a6;
9566 }
9567 if (!isTextDecl)
9568 {
9569 attr = AddAttributeNoChecks("version", 1);
9570 }
9571 }
9572 else
9573 {
9574 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, num2 - _ps.charPos, "standalone") || (xmlDeclState != 1 && xmlDeclState != 2) || isTextDecl)
9575 {
9576 goto IL_06a6;
9577 }
9578 if (!isTextDecl)
9579 {
9580 attr = AddAttributeNoChecks("standalone", 1);
9581 }
9582 xmlDeclState = 2;
9583 }
9584 }
9585 else
9586 {
9587 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, num2 - _ps.charPos, "encoding") || (xmlDeclState != 1 && (!isTextDecl || xmlDeclState != 0)))
9588 {
9589 goto IL_06a6;
9590 }
9591 if (!isTextDecl)
9592 {
9593 attr = AddAttributeNoChecks("encoding", 1);
9594 }
9595 xmlDeclState = 1;
9596 }
9597 goto IL_06c0;
9598 IL_06c0:
9599 if (!isTextDecl)
9600 {
9601 attr.SetLineInfo(_ps.LineNo, _ps.LinePos);
9602 }
9604 _ps.charPos = num2;
9605 if (_ps.chars[_ps.charPos] != '=')
9606 {
9607 await EatWhitespacesAsync(sb).ConfigureAwait(continueOnCapturedContext: false);
9608 if (_ps.chars[_ps.charPos] != '=')
9609 {
9611 }
9612 }
9613 sb.Append('=');
9614 _ps.charPos++;
9615 char quoteChar = _ps.chars[_ps.charPos];
9616 if (quoteChar != '"' && quoteChar != '\'')
9617 {
9618 await EatWhitespacesAsync(sb).ConfigureAwait(continueOnCapturedContext: false);
9619 quoteChar = _ps.chars[_ps.charPos];
9620 if (quoteChar != '"' && quoteChar != '\'')
9621 {
9622 ThrowUnexpectedToken("\"", "'");
9623 }
9624 }
9625 sb.Append(quoteChar);
9626 _ps.charPos++;
9627 if (!isTextDecl)
9628 {
9629 attr.quoteChar = quoteChar;
9630 attr.SetLineInfo2(_ps.LineNo, _ps.LinePos);
9631 }
9632 int pos = _ps.charPos;
9633 char[] chars;
9634 while (true)
9635 {
9636 for (chars = _ps.chars; XmlCharType.IsAttributeValueChar(chars[pos]); pos++)
9637 {
9638 }
9639 if (_ps.chars[pos] == quoteChar)
9640 {
9641 break;
9642 }
9643 if (pos == _ps.charsUsed)
9644 {
9645 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) != 0)
9646 {
9647 continue;
9648 }
9649 goto IL_0c8b;
9650 }
9651 goto IL_0c98;
9652 }
9653 switch (xmlDeclState)
9654 {
9655 case 0:
9656 if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, pos - _ps.charPos, "1.0"))
9657 {
9658 if (!isTextDecl)
9659 {
9660 attr.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos);
9661 }
9662 xmlDeclState = 1;
9663 }
9664 else
9665 {
9666 string arg = new string(_ps.chars, _ps.charPos, pos - _ps.charPos);
9668 }
9669 break;
9670 case 1:
9671 {
9672 string text = new string(_ps.chars, _ps.charPos, pos - _ps.charPos);
9673 encoding = CheckEncoding(text);
9674 if (!isTextDecl)
9675 {
9676 attr.SetValue(text);
9677 }
9678 xmlDeclState = 2;
9679 break;
9680 }
9681 case 2:
9682 if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, pos - _ps.charPos, "yes"))
9683 {
9684 _standalone = true;
9685 }
9686 else if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, pos - _ps.charPos, "no"))
9687 {
9688 _standalone = false;
9689 }
9690 else
9691 {
9693 }
9694 if (!isTextDecl)
9695 {
9696 attr.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos);
9697 }
9698 xmlDeclState = 3;
9699 break;
9700 }
9701 sb.Append(chars, _ps.charPos, pos - _ps.charPos);
9702 sb.Append(quoteChar);
9703 _ps.charPos = pos + 1;
9704 continue;
9705 IL_0cb2:
9706 bool isEof = _ps.isEof;
9707 bool flag = isEof;
9708 if (!flag)
9709 {
9710 flag = await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0;
9711 }
9712 if (flag)
9713 {
9715 }
9716 continue;
9717 IL_0c98:
9719 goto IL_0cb2;
9720 IL_0c8b:
9722 goto IL_0cb2;
9723 IL_06a6:
9725 goto IL_06c0;
9726 }
9727 if (xmlDeclState == 0)
9728 {
9730 }
9731 _ps.charPos += 2;
9732 if (!isTextDecl)
9733 {
9735 sb.Length = 0;
9737 _parsingFunction = ParsingFunction.ResetAttributesRootLevel;
9738 }
9739 if (encoding != null)
9740 {
9742 }
9743 else
9744 {
9745 if (isTextDecl)
9746 {
9748 }
9749 if (_afterResetState)
9750 {
9751 string webName = _ps.encoding.WebName;
9752 if (webName != "utf-8" && webName != "utf-16" && webName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding))
9753 {
9754 Throw(System.SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
9755 }
9756 }
9758 {
9760 }
9761 }
9762 _ps.appendMode = false;
9763 return true;
9764 }
9765 while (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) != 0);
9766 if (!isTextDecl)
9767 {
9769 }
9770 if (_afterResetState)
9771 {
9772 string webName2 = _ps.encoding.WebName;
9773 if (webName2 != "utf-8" && webName2 != "utf-16" && webName2 != "utf-16BE" && !(_ps.encoding is Ucs4Encoding))
9774 {
9775 Throw(System.SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
9776 }
9777 }
9779 {
9781 }
9782 _ps.appendMode = false;
9783 return false;
9784 }
9785
9787 {
9788 char[] chars;
9789 bool needMoreChars;
9790 int charPos;
9791 while (true)
9792 {
9793 needMoreChars = false;
9794 charPos = _ps.charPos;
9795 chars = _ps.chars;
9796 if (chars[charPos] != '<')
9797 {
9798 break;
9799 }
9800 needMoreChars = true;
9801 if (_ps.charsUsed - charPos < 4)
9802 {
9804 }
9805 charPos++;
9806 switch (chars[charPos])
9807 {
9808 case '?':
9809 _ps.charPos = charPos + 1;
9810 return ParsePIAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseDocumentContentAsync(), this);
9811 case '!':
9812 charPos++;
9813 if (_ps.charsUsed - charPos < 2)
9814 {
9816 }
9817 if (chars[charPos] == '-')
9818 {
9819 if (chars[charPos + 1] == '-')
9820 {
9821 _ps.charPos = charPos + 2;
9822 return ParseCommentAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseDocumentContentAsync(), this);
9823 }
9824 ThrowUnexpectedToken(charPos + 1, "-");
9825 continue;
9826 }
9827 if (chars[charPos] == '[')
9828 {
9829 if (_fragmentType != XmlNodeType.Document)
9830 {
9831 charPos++;
9832 if (_ps.charsUsed - charPos < 6)
9833 {
9835 }
9836 if (XmlConvert.StrEqual(chars, charPos, 6, "CDATA["))
9837 {
9838 _ps.charPos = charPos + 6;
9839 return ParseCDataAsync().CallBoolTaskFuncWhenFinishAsync((XmlTextReaderImpl thisRef) => thisRef.ParseDocumentContentAsync_CData(), this);
9840 }
9841 ThrowUnexpectedToken(charPos, "CDATA[");
9842 }
9843 else
9844 {
9846 }
9847 continue;
9848 }
9849 if (_fragmentType == XmlNodeType.Document || _fragmentType == XmlNodeType.None)
9850 {
9851 _fragmentType = XmlNodeType.Document;
9852 _ps.charPos = charPos;
9853 return ParseDoctypeDeclAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseDocumentContentAsync(), this);
9854 }
9855 if (ParseUnexpectedToken(charPos) == "DOCTYPE")
9856 {
9858 }
9859 else
9860 {
9861 ThrowUnexpectedToken(charPos, "<!--", "<[CDATA[");
9862 }
9863 continue;
9864 case '/':
9865 Throw(charPos + 1, System.SR.Xml_UnexpectedEndTag);
9866 continue;
9867 }
9869 {
9870 if (_fragmentType == XmlNodeType.Document)
9871 {
9872 Throw(charPos, System.SR.Xml_MultipleRoots);
9873 }
9874 if (_fragmentType == XmlNodeType.None)
9875 {
9876 _fragmentType = XmlNodeType.Element;
9877 }
9878 }
9879 _ps.charPos = charPos;
9880 _rootElementParsed = true;
9881 return ParseElementAsync().ReturnTrueTaskWhenFinishAsync();
9882 }
9883 if (chars[charPos] == '&')
9884 {
9886 }
9887 if (charPos == _ps.charsUsed || (_v1Compat && chars[charPos] == '\0'))
9888 {
9890 }
9891 if (_fragmentType == XmlNodeType.Document)
9892 {
9893 return ParseRootLevelWhitespaceAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseDocumentContentAsync(), this);
9894 }
9896 }
9897
9899 {
9900 if (_fragmentType == XmlNodeType.None)
9901 {
9902 _fragmentType = XmlNodeType.Element;
9903 }
9905 }
9906
9908 {
9909 int charPos = _ps.charPos;
9910 if (_fragmentType == XmlNodeType.Document)
9911 {
9913 return false;
9914 }
9915 if (_fragmentType == XmlNodeType.None)
9916 {
9917 _fragmentType = XmlNodeType.Element;
9918 }
9919 switch ((await HandleEntityReferenceAsync(isInAttributeValue: false, EntityExpandType.OnlyGeneral).ConfigureAwait(continueOnCapturedContext: false)).Item2)
9920 {
9921 case EntityType.Unexpanded:
9922 if (_parsingFunction == ParsingFunction.EntityReference)
9923 {
9925 }
9927 return true;
9928 case EntityType.CharacterDec:
9929 case EntityType.CharacterHex:
9930 case EntityType.CharacterNamed:
9932 {
9933 return true;
9934 }
9936 default:
9938 }
9939 }
9940
9942 {
9944 if (task.IsSuccess())
9945 {
9946 if (task.Result)
9947 {
9948 if (_fragmentType == XmlNodeType.None && _curNode.type == XmlNodeType.Text)
9949 {
9950 _fragmentType = XmlNodeType.Element;
9951 }
9953 }
9955 }
9957 }
9958
9960 {
9961 if (await task.ConfigureAwait(continueOnCapturedContext: false))
9962 {
9963 if (_fragmentType == XmlNodeType.None && _curNode.type == XmlNodeType.Text)
9964 {
9965 _fragmentType = XmlNodeType.Element;
9966 }
9967 return true;
9968 }
9970 }
9971
9973 {
9974 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) != 0)
9975 {
9977 }
9978 if (needMoreChars)
9979 {
9981 }
9982 if (InEntity)
9983 {
9985 {
9987 return true;
9988 }
9990 }
9991 if (!_rootElementParsed && _fragmentType == XmlNodeType.Document)
9992 {
9994 }
9995 if (_fragmentType == XmlNodeType.None)
9996 {
9997 _fragmentType = ((!_rootElementParsed) ? XmlNodeType.Element : XmlNodeType.Document);
9998 }
9999 OnEof();
10000 return false;
10001 }
10002
10004 {
10005 while (true)
10006 {
10007 int charPos = _ps.charPos;
10008 char[] chars = _ps.chars;
10009 switch (chars[charPos])
10010 {
10011 case '<':
10012 switch (chars[charPos + 1])
10013 {
10014 case '?':
10015 _ps.charPos = charPos + 2;
10016 return ParsePIAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseElementContentAsync(), this);
10017 case '!':
10018 charPos += 2;
10019 if (_ps.charsUsed - charPos < 2)
10020 {
10022 }
10023 if (chars[charPos] == '-')
10024 {
10025 if (chars[charPos + 1] == '-')
10026 {
10027 _ps.charPos = charPos + 2;
10028 return ParseCommentAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseElementContentAsync(), this);
10029 }
10030 ThrowUnexpectedToken(charPos + 1, "-");
10031 }
10032 else if (chars[charPos] == '[')
10033 {
10034 charPos++;
10035 if (_ps.charsUsed - charPos < 6)
10036 {
10038 }
10039 if (XmlConvert.StrEqual(chars, charPos, 6, "CDATA["))
10040 {
10041 _ps.charPos = charPos + 6;
10042 return ParseCDataAsync().ReturnTrueTaskWhenFinishAsync();
10043 }
10044 ThrowUnexpectedToken(charPos, "CDATA[");
10045 }
10046 else if (ParseUnexpectedToken(charPos) == "DOCTYPE")
10047 {
10049 }
10050 else
10051 {
10052 ThrowUnexpectedToken(charPos, "<!--", "<[CDATA[");
10053 }
10054 break;
10055 case '/':
10056 _ps.charPos = charPos + 2;
10057 return ParseEndElementAsync().ReturnTrueTaskWhenFinishAsync();
10058 default:
10059 if (charPos + 1 == _ps.charsUsed)
10060 {
10062 }
10063 _ps.charPos = charPos + 1;
10064 return ParseElementAsync().ReturnTrueTaskWhenFinishAsync();
10065 }
10066 break;
10067 case '&':
10068 return ParseTextAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseElementContentAsync(), this);
10069 default:
10070 if (charPos == _ps.charsUsed)
10071 {
10073 }
10074 return ParseTextAsync().ContinueBoolTaskFuncWhenFalseAsync((XmlTextReaderImpl thisRef) => thisRef.ParseElementContentAsync(), this);
10075 }
10076 }
10077 }
10078
10080 {
10081 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
10082 {
10083 if (_ps.charsUsed - _ps.charPos != 0)
10084 {
10086 }
10087 if (!InEntity)
10088 {
10089 if (_index == 0 && _fragmentType != XmlNodeType.Document)
10090 {
10091 OnEof();
10092 return false;
10093 }
10095 }
10097 {
10099 return true;
10100 }
10101 }
10103 }
10104
10106 {
10107 int num = _ps.charPos;
10108 char[] chars = _ps.chars;
10109 int num2 = -1;
10111 while (true)
10112 {
10114 {
10115 num++;
10116 while (true)
10117 {
10119 {
10120 num++;
10121 continue;
10122 }
10123 if (chars[num] != ':')
10124 {
10125 break;
10126 }
10127 if (num2 == -1)
10128 {
10129 goto IL_0088;
10130 }
10131 if (!_supportNamespaces)
10132 {
10133 num++;
10134 continue;
10135 }
10136 goto IL_006c;
10137 }
10138 if (num + 1 < _ps.charsUsed)
10139 {
10140 break;
10141 }
10142 }
10143 goto IL_00a0;
10144 IL_0088:
10145 num2 = num;
10146 num++;
10147 continue;
10148 IL_00a0:
10151 IL_006c:
10153 goto IL_00a0;
10154 }
10156 }
10157
10159 {
10160 if (task.IsSuccess())
10161 {
10162 var (colonPos, pos) = task.Result;
10164 }
10166 }
10167
10173
10175 {
10176 char[] chars = _ps.chars;
10178 if (colonPos == -1 || !_supportNamespaces)
10179 {
10181 }
10182 else
10183 {
10184 int charPos = _ps.charPos;
10185 int num = colonPos - charPos;
10186 if (num == _lastPrefix.Length && XmlConvert.StrEqual(chars, charPos, num, _lastPrefix))
10187 {
10189 }
10190 else
10191 {
10194 }
10195 }
10196 char ch = chars[pos];
10197 bool flag = XmlCharType.IsWhiteSpace(ch);
10198 _ps.charPos = pos;
10199 if (flag)
10200 {
10201 return ParseAttributesAsync();
10202 }
10204 }
10205
10207 {
10208 int charPos = _ps.charPos;
10209 char[] chars = _ps.chars;
10210 switch (chars[charPos])
10211 {
10212 case '>':
10213 _ps.charPos = charPos + 1;
10214 _parsingFunction = ParsingFunction.MoveToElementContent;
10215 break;
10216 case '/':
10217 if (charPos + 1 == _ps.charsUsed)
10218 {
10219 _ps.charPos = charPos;
10220 return ParseElementAsync_ReadData(charPos);
10221 }
10222 if (chars[charPos + 1] == '>')
10223 {
10226 _parsingFunction = ParsingFunction.PopEmptyElementContext;
10227 _ps.charPos = charPos + 2;
10228 }
10229 else
10230 {
10231 ThrowUnexpectedToken(charPos, ">");
10232 }
10233 break;
10234 default:
10236 break;
10237 }
10239 {
10241 }
10243 return Task.CompletedTask;
10244 }
10245
10247 {
10248 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
10249 {
10250 Throw(pos, System.SR.Xml_UnexpectedEOF, ">");
10251 }
10253 }
10254
10256 {
10258 int length = nodeData.prefix.Length;
10259 int length2 = nodeData.localName.Length;
10260 if (_ps.charsUsed - _ps.charPos < length + length2 + 1)
10261 {
10262 return _ParseEndElmentAsync();
10263 }
10265 }
10266
10272
10274 {
10276 int prefLen = nodeData.prefix.Length;
10277 int locLen = nodeData.localName.Length;
10278 while (_ps.charsUsed - _ps.charPos < prefLen + locLen + 1 && await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) != 0)
10279 {
10280 }
10281 }
10282
10284 {
10286 int length = nodeData.prefix.Length;
10287 int length2 = nodeData.localName.Length;
10288 char[] chars = _ps.chars;
10289 int nameLen;
10290 if (nodeData.prefix.Length == 0)
10291 {
10292 if (!XmlConvert.StrEqual(chars, _ps.charPos, length2, nodeData.localName))
10293 {
10295 }
10296 nameLen = length2;
10297 }
10298 else
10299 {
10300 int num = _ps.charPos + length;
10301 if (!XmlConvert.StrEqual(chars, _ps.charPos, length, nodeData.prefix) || chars[num] != ':' || !XmlConvert.StrEqual(chars, num + 1, length2, nodeData.localName))
10302 {
10304 }
10305 nameLen = length2 + length + 1;
10306 }
10309 }
10310
10312 {
10314 while (task.IsSuccess())
10315 {
10317 {
10318 case ParseEndElementParseFunction.CheckEndTag:
10320 break;
10321 case ParseEndElementParseFunction.ReadData:
10323 break;
10325 return task;
10326 }
10327 }
10329 }
10330
10332 {
10333 while (true)
10334 {
10335 await task.ConfigureAwait(continueOnCapturedContext: false);
10337 {
10338 case ParseEndElementParseFunction.CheckEndTag:
10340 break;
10341 case ParseEndElementParseFunction.ReadData:
10343 break;
10345 return;
10346 }
10347 }
10348 }
10349
10351 {
10352 int num;
10353 while (true)
10354 {
10355 num = _ps.charPos + nameLen;
10356 char[] chars = _ps.chars;
10357 if (num == _ps.charsUsed)
10358 {
10360 return Task.CompletedTask;
10361 }
10362 bool flag = false;
10363 if (XmlCharType.IsNCNameSingleChar(chars[num]) || chars[num] == ':')
10364 {
10365 flag = true;
10366 }
10367 if (flag)
10368 {
10370 }
10371 if (chars[num] != '>')
10372 {
10373 char c;
10374 while (XmlCharType.IsWhiteSpace(c = chars[num]))
10375 {
10376 num++;
10377 switch (c)
10378 {
10379 case '\n':
10380 OnNewLine(num);
10381 break;
10382 case '\r':
10383 if (chars[num] == '\n')
10384 {
10385 num++;
10386 }
10387 else if (num == _ps.charsUsed && !_ps.isEof)
10388 {
10389 break;
10390 }
10391 OnNewLine(num);
10392 break;
10393 }
10394 }
10395 }
10396 if (chars[num] == '>')
10397 {
10398 break;
10399 }
10400 if (num == _ps.charsUsed)
10401 {
10403 return Task.CompletedTask;
10404 }
10405 ThrowUnexpectedToken(num, ">");
10406 }
10407 _index--;
10410 startTagNode.type = XmlNodeType.EndElement;
10411 _ps.charPos = num + 1;
10412 _nextParsingFunction = ((_index > 0) ? _parsingFunction : ParsingFunction.DocumentContent);
10413 _parsingFunction = ParsingFunction.PopElementContext;
10415 return Task.CompletedTask;
10416 }
10417
10419 {
10420 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
10421 {
10423 }
10425 }
10426
10428 {
10429 if (startTag.type == XmlNodeType.Element)
10430 {
10431 (int, int) tuple = await ParseQNameAsync().ConfigureAwait(continueOnCapturedContext: false);
10432 _ = tuple.Item1;
10433 int item = tuple.Item2;
10434 Throw(args: new string[4]
10435 {
10436 startTag.GetNameWPrefix(_nameTable),
10437 startTag.lineInfo.lineNo.ToString(CultureInfo.InvariantCulture),
10438 startTag.lineInfo.linePos.ToString(CultureInfo.InvariantCulture),
10441 }
10442 else
10443 {
10445 }
10446 }
10447
10449 {
10450 int pos = _ps.charPos;
10451 char[] chars = _ps.chars;
10452 while (true)
10453 {
10454 int num = 0;
10455 while (true)
10456 {
10457 char c;
10458 int num2;
10459 if (XmlCharType.IsWhiteSpace(c = chars[pos]))
10460 {
10461 switch (c)
10462 {
10463 case '\n':
10464 OnNewLine(pos + 1);
10465 num++;
10466 goto IL_00f2;
10467 case '\r':
10468 if (chars[pos + 1] == '\n')
10469 {
10470 OnNewLine(pos + 2);
10471 num++;
10472 pos++;
10473 goto IL_00f2;
10474 }
10475 if (pos + 1 != _ps.charsUsed)
10476 {
10477 OnNewLine(pos + 1);
10478 num++;
10479 goto IL_00f2;
10480 }
10481 break;
10482 default:
10483 goto IL_00f2;
10484 }
10485 _ps.charPos = pos;
10486 }
10487 else
10488 {
10489 num2 = 0;
10490 char c2;
10492 {
10493 num2 = 1;
10494 }
10495 if (num2 != 0)
10496 {
10497 goto IL_0234;
10498 }
10499 if (c2 == '>')
10500 {
10501 _ps.charPos = pos + 1;
10502 _parsingFunction = ParsingFunction.MoveToElementContent;
10503 goto IL_090f;
10504 }
10505 if (c2 == '/')
10506 {
10507 if (pos + 1 != _ps.charsUsed)
10508 {
10509 if (chars[pos + 1] == '>')
10510 {
10511 _ps.charPos = pos + 2;
10514 _parsingFunction = ParsingFunction.PopEmptyElementContext;
10515 goto IL_090f;
10516 }
10517 ThrowUnexpectedToken(pos + 1, ">");
10518 goto IL_0234;
10519 }
10520 }
10521 else if (pos != _ps.charsUsed)
10522 {
10523 if (c2 != ':' || _supportNamespaces)
10524 {
10526 }
10527 goto IL_0234;
10528 }
10529 }
10530 _ps.lineNo -= num;
10531 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) != 0)
10532 {
10533 pos = _ps.charPos;
10534 chars = _ps.chars;
10535 }
10536 else
10537 {
10539 }
10540 break;
10541 IL_090f:
10543 {
10545 }
10548 {
10551 }
10552 if (_attrDuplWalkCount >= 250)
10553 {
10555 }
10556 return;
10557 IL_00f2:
10558 pos++;
10559 continue;
10560 IL_0234:
10561 if (pos == _ps.charPos)
10562 {
10564 }
10565 _ps.charPos = pos;
10567 int num3 = -1;
10568 pos += num2;
10569 while (true)
10570 {
10571 char c3;
10573 {
10574 pos++;
10575 continue;
10576 }
10577 if (c3 == ':')
10578 {
10579 if (num3 != -1)
10580 {
10582 {
10584 break;
10585 }
10586 pos++;
10587 continue;
10588 }
10589 num3 = pos;
10590 pos++;
10592 {
10593 pos++;
10594 continue;
10595 }
10596 (int, int) tuple = await ParseQNameAsync().ConfigureAwait(continueOnCapturedContext: false);
10597 num3 = tuple.Item1;
10598 pos = tuple.Item2;
10599 chars = _ps.chars;
10600 break;
10601 }
10602 if (pos + 1 >= _ps.charsUsed)
10603 {
10604 (int, int) tuple2 = await ParseQNameAsync().ConfigureAwait(continueOnCapturedContext: false);
10605 num3 = tuple2.Item1;
10606 pos = tuple2.Item2;
10607 chars = _ps.chars;
10608 }
10609 break;
10610 }
10612 attr.SetLineInfo(_ps.LineNo, attrNameLinePos);
10613 if (chars[pos] != '=')
10614 {
10615 _ps.charPos = pos;
10616 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
10617 pos = _ps.charPos;
10618 if (chars[pos] != '=')
10619 {
10621 }
10622 }
10623 pos++;
10624 char c4 = chars[pos];
10625 if (c4 != '"' && c4 != '\'')
10626 {
10627 _ps.charPos = pos;
10628 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
10629 pos = _ps.charPos;
10630 c4 = chars[pos];
10631 if (c4 != '"' && c4 != '\'')
10632 {
10633 ThrowUnexpectedToken("\"", "'");
10634 }
10635 }
10636 pos++;
10637 _ps.charPos = pos;
10639 attr.SetLineInfo2(_ps.LineNo, _ps.LinePos);
10640 char c5;
10642 {
10643 pos++;
10644 }
10645 if (c5 == c4)
10646 {
10647 attr.SetValue(chars, _ps.charPos, pos - _ps.charPos);
10648 pos++;
10649 _ps.charPos = pos;
10650 }
10651 else
10652 {
10654 pos = _ps.charPos;
10655 chars = _ps.chars;
10656 }
10657 if (attr.prefix.Length == 0)
10658 {
10659 if (Ref.Equal(attr.localName, _xmlNs))
10660 {
10662 }
10663 }
10664 else if (Ref.Equal(attr.prefix, _xmlNs))
10665 {
10667 }
10668 else if (Ref.Equal(attr.prefix, _xml))
10669 {
10671 }
10672 break;
10673 }
10674 }
10675 }
10676
10678 {
10679 int pos = curPos;
10680 char[] chars = _ps.chars;
10682 int valueChunkStartPos = 0;
10684 NodeData lastChunk = null;
10685 while (true)
10686 {
10688 {
10689 pos++;
10690 continue;
10691 }
10692 if (pos - _ps.charPos > 0)
10693 {
10695 _ps.charPos = pos;
10696 }
10697 if (chars[pos] == quoteChar && attributeBaseEntityId == _ps.entityId)
10698 {
10699 break;
10700 }
10701 switch (chars[pos])
10702 {
10703 case '\n':
10704 pos++;
10705 OnNewLine(pos);
10706 if (_normalize)
10707 {
10709 _ps.charPos++;
10710 }
10711 continue;
10712 case '\r':
10713 if (chars[pos + 1] == '\n')
10714 {
10715 pos += 2;
10716 if (_normalize)
10717 {
10719 _ps.charPos = pos;
10720 }
10721 }
10722 else
10723 {
10724 if (pos + 1 >= _ps.charsUsed && !_ps.isEof)
10725 {
10726 break;
10727 }
10728 pos++;
10729 if (_normalize)
10730 {
10732 _ps.charPos = pos;
10733 }
10734 }
10735 OnNewLine(pos);
10736 continue;
10737 case '\t':
10738 pos++;
10739 if (_normalize)
10740 {
10742 _ps.charPos++;
10743 }
10744 continue;
10745 case '"':
10746 case '\'':
10747 case '>':
10748 pos++;
10749 continue;
10750 case '<':
10752 break;
10753 case '&':
10754 {
10755 if (pos - _ps.charPos > 0)
10756 {
10758 }
10759 _ps.charPos = pos;
10763 (pos, _) = tuple;
10764 switch (tuple.Item2)
10765 {
10766 case EntityType.Unexpanded:
10768 {
10770 if (num2 > 0)
10771 {
10772 NodeData nodeData3 = new NodeData();
10777 }
10778 _ps.charPos++;
10779 string text = await ParseEntityNameAsync().ConfigureAwait(continueOnCapturedContext: false);
10780 NodeData nodeData4 = new NodeData();
10783 nodeData4.SetNamedNode(XmlNodeType.EntityReference, text);
10790 _fullAttrCleanup = true;
10791 }
10792 else
10793 {
10794 _ps.charPos++;
10795 await ParseEntityNameAsync().ConfigureAwait(continueOnCapturedContext: false);
10796 }
10797 pos = _ps.charPos;
10798 break;
10799 case EntityType.ExpandedInAttribute:
10801 {
10803 if (num > 0)
10804 {
10805 NodeData nodeData = new NodeData();
10810 }
10811 NodeData nodeData2 = new NodeData();
10814 nodeData2.SetNamedNode(XmlNodeType.EntityReference, _ps.entity.Name);
10816 _fullAttrCleanup = true;
10817 }
10818 pos = _ps.charPos;
10819 break;
10820 default:
10821 pos = _ps.charPos;
10822 break;
10823 case EntityType.CharacterDec:
10824 case EntityType.CharacterHex:
10825 case EntityType.CharacterNamed:
10826 break;
10827 }
10828 chars = _ps.chars;
10829 continue;
10830 }
10831 default:
10832 {
10833 if (pos == _ps.charsUsed)
10834 {
10835 break;
10836 }
10837 char ch = chars[pos];
10839 {
10840 if (pos + 1 == _ps.charsUsed)
10841 {
10842 break;
10843 }
10844 pos++;
10846 {
10847 pos++;
10848 continue;
10849 }
10850 }
10852 break;
10853 }
10854 }
10855 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
10856 {
10857 if (_ps.charsUsed - _ps.charPos > 0)
10858 {
10859 if (_ps.chars[_ps.charPos] != '\r')
10860 {
10862 }
10863 }
10864 else
10865 {
10866 if (!InEntity)
10867 {
10868 if (_fragmentType == XmlNodeType.Attribute)
10869 {
10871 {
10873 }
10874 break;
10875 }
10877 }
10879 {
10881 }
10883 {
10886 }
10887 }
10888 }
10889 pos = _ps.charPos;
10890 chars = _ps.chars;
10891 }
10892 if (attr.nextAttrValueChunk != null)
10893 {
10895 if (num3 > 0)
10896 {
10897 NodeData nodeData5 = new NodeData();
10902 }
10903 }
10904 _ps.charPos = pos + 1;
10905 attr.SetValue(_stringBuilder.ToString());
10907 }
10908
10910 {
10911 int outOrChars = 0;
10912 if (_parsingMode != 0)
10913 {
10914 return _ParseTextAsync(null);
10915 }
10917 ValueTask<(int, int, int, bool)> valueTask = ParseTextAsync(outOrChars).Preserve();
10918 bool flag = false;
10919 if (!valueTask.IsCompletedSuccessfully)
10920 {
10921 return _ParseTextAsync(valueTask.AsTask());
10922 }
10923 (int, int, int, bool) result = valueTask.Result;
10924 int num;
10925 int num2;
10926 (num, num2, outOrChars, _) = result;
10927 if (result.Item4)
10928 {
10929 if (num2 - num == 0)
10930 {
10932 }
10934 if (textNodeType == XmlNodeType.None)
10935 {
10937 }
10940 }
10941 return _ParseTextAsync(valueTask.AsTask());
10942 }
10943
10944 private async Task<bool> _ParseTextAsync(Task<(int, int, int, bool)> parseTask)
10945 {
10946 int outOrChars = 0;
10947 if (parseTask == null)
10948 {
10949 if (_parsingMode != 0)
10950 {
10951 (int, int, int, bool) tuple;
10952 do
10953 {
10955 _ = tuple.Item1;
10956 _ = tuple.Item2;
10957 outOrChars = tuple.Item3;
10958 }
10959 while (!tuple.Item4);
10960 goto IL_0574;
10961 }
10963 parseTask = ParseTextAsync(outOrChars).AsTask();
10964 }
10965 (int, int, int, bool) tuple2 = await parseTask.ConfigureAwait(continueOnCapturedContext: false);
10966 int num;
10967 int num2;
10968 (num, num2, outOrChars, _) = tuple2;
10969 if (tuple2.Item4)
10970 {
10971 if (num2 - num != 0)
10972 {
10974 if (textNodeType != 0)
10975 {
10977 return true;
10978 }
10979 }
10980 }
10981 else if (_v1Compat)
10982 {
10983 (int, int, int, bool) tuple4;
10984 do
10985 {
10986 if (num2 - num > 0)
10987 {
10988 _stringBuilder.Append(_ps.chars, num, num2 - num);
10989 }
10991 (num, num2, outOrChars, _) = tuple4;
10992 }
10993 while (!tuple4.Item4);
10994 if (num2 - num > 0)
10995 {
10996 _stringBuilder.Append(_ps.chars, num, num2 - num);
10997 }
10999 if (textNodeType2 != 0)
11000 {
11003 return true;
11004 }
11006 }
11007 else
11008 {
11009 if (outOrChars > 32)
11010 {
11011 _curNode.SetValueNode(XmlNodeType.Text, _ps.chars, num, num2 - num);
11013 _parsingFunction = ParsingFunction.PartialTextValue;
11014 return true;
11015 }
11016 if (num2 - num > 0)
11017 {
11018 _stringBuilder.Append(_ps.chars, num, num2 - num);
11019 }
11020 bool flag;
11021 do
11022 {
11023 (num, num2, outOrChars, flag) = await ParseTextAsync(outOrChars).ConfigureAwait(continueOnCapturedContext: false);
11024 if (num2 - num > 0)
11025 {
11026 _stringBuilder.Append(_ps.chars, num, num2 - num);
11027 }
11028 }
11029 while (!flag && outOrChars <= 32 && _stringBuilder.Length < 4096);
11031 if (xmlNodeType != 0)
11032 {
11035 if (!flag)
11036 {
11038 _parsingFunction = ParsingFunction.PartialTextValue;
11039 }
11040 return true;
11041 }
11043 if (!flag)
11044 {
11045 (int, int, int, bool) tuple7;
11046 do
11047 {
11049 _ = tuple7.Item1;
11050 _ = tuple7.Item2;
11051 outOrChars = tuple7.Item3;
11052 }
11053 while (!tuple7.Item4);
11054 }
11055 }
11056 goto IL_0574;
11057 IL_0574:
11059 }
11060
11062 {
11063 if (_parsingFunction == ParsingFunction.ReportEndEntity)
11064 {
11068 }
11069 if (_parsingFunction == ParsingFunction.EntityReference)
11070 {
11072 return ParseEntityReferenceAsync().ReturnTrueTaskWhenFinishAsync();
11073 }
11075 }
11076
11077 private ValueTask<(int, int, int, bool)> ParseTextAsync(int outOrChars)
11078 {
11079 Task<(int, int, int, bool)> task = ParseTextAsync(outOrChars, _ps.chars, _ps.charPos, 0, -1, outOrChars, '\0');
11080 while (task.IsSuccess())
11081 {
11082 outOrChars = _lastParseTextState.outOrChars;
11084 int pos = _lastParseTextState.pos;
11085 int rcount = _lastParseTextState.rcount;
11086 int rpos = _lastParseTextState.rpos;
11087 int orChars = _lastParseTextState.orChars;
11088 char c = _lastParseTextState.c;
11090 {
11091 case ParseTextFunction.ParseText:
11092 task = ParseTextAsync(outOrChars, chars, pos, rcount, rpos, orChars, c);
11093 break;
11094 case ParseTextFunction.Entity:
11095 task = ParseTextAsync_ParseEntity(outOrChars, chars, pos, rcount, rpos, orChars, c);
11096 break;
11097 case ParseTextFunction.ReadData:
11098 task = ParseTextAsync_ReadData(outOrChars, chars, pos, rcount, rpos, orChars, c);
11099 break;
11100 case ParseTextFunction.Surrogate:
11101 task = ParseTextAsync_Surrogate(outOrChars, chars, pos, rcount, rpos, orChars, c);
11102 break;
11103 case ParseTextFunction.NoValue:
11104 return new ValueTask<(int, int, int, bool)>(ParseText_NoValue(outOrChars, pos));
11105 case ParseTextFunction.PartialValue:
11106 return new ValueTask<(int, int, int, bool)>(ParseText_PartialValue(pos, rcount, rpos, orChars, c));
11107 }
11108 }
11110 }
11111
11112 private async Task<(int, int, int, bool)> ParseTextAsync_AsyncFunc(Task<(int, int, int, bool)> task)
11113 {
11114 while (true)
11115 {
11116 await task.ConfigureAwait(continueOnCapturedContext: false);
11117 int outOrChars = _lastParseTextState.outOrChars;
11119 int pos = _lastParseTextState.pos;
11120 int rcount = _lastParseTextState.rcount;
11121 int rpos = _lastParseTextState.rpos;
11122 int orChars = _lastParseTextState.orChars;
11123 char c = _lastParseTextState.c;
11125 {
11126 case ParseTextFunction.ParseText:
11127 task = ParseTextAsync(outOrChars, chars, pos, rcount, rpos, orChars, c);
11128 break;
11129 case ParseTextFunction.Entity:
11130 task = ParseTextAsync_ParseEntity(outOrChars, chars, pos, rcount, rpos, orChars, c);
11131 break;
11132 case ParseTextFunction.ReadData:
11133 task = ParseTextAsync_ReadData(outOrChars, chars, pos, rcount, rpos, orChars, c);
11134 break;
11135 case ParseTextFunction.Surrogate:
11136 task = ParseTextAsync_Surrogate(outOrChars, chars, pos, rcount, rpos, orChars, c);
11137 break;
11138 case ParseTextFunction.NoValue:
11139 return ParseText_NoValue(outOrChars, pos);
11140 case ParseTextFunction.PartialValue:
11141 return ParseText_PartialValue(pos, rcount, rpos, orChars, c);
11142 }
11143 }
11144 }
11145
11146 private Task<(int, int, int, bool)> ParseTextAsync(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
11147 {
11148 while (true)
11149 {
11150 if (XmlCharType.IsTextChar(c = chars[pos]))
11151 {
11152 orChars |= c;
11153 pos++;
11154 continue;
11155 }
11156 switch (c)
11157 {
11158 case '\t':
11159 pos++;
11160 break;
11161 case '\n':
11162 pos++;
11163 OnNewLine(pos);
11164 break;
11165 case '\r':
11166 if (chars[pos + 1] == '\n')
11167 {
11168 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
11169 {
11170 if (pos - _ps.charPos > 0)
11171 {
11172 if (rcount == 0)
11173 {
11174 rcount = 1;
11175 rpos = pos;
11176 }
11177 else
11178 {
11179 ShiftBuffer(rpos + rcount, rpos, pos - rpos - rcount);
11180 rpos = pos - rcount;
11181 rcount++;
11182 }
11183 }
11184 else
11185 {
11186 _ps.charPos++;
11187 }
11188 }
11189 pos += 2;
11190 }
11191 else
11192 {
11193 if (pos + 1 >= _ps.charsUsed && !_ps.isEof)
11194 {
11195 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11197 return _parseText_dummyTask;
11198 }
11199 if (!_ps.eolNormalized)
11200 {
11201 chars[pos] = '\n';
11202 }
11203 pos++;
11204 }
11205 OnNewLine(pos);
11206 break;
11207 case '<':
11208 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11210 return _parseText_dummyTask;
11211 case '&':
11212 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11214 return _parseText_dummyTask;
11215 case ']':
11216 if (_ps.charsUsed - pos < 3 && !_ps.isEof)
11217 {
11218 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11220 return _parseText_dummyTask;
11221 }
11222 if (chars[pos + 1] == ']' && chars[pos + 2] == '>')
11223 {
11225 }
11226 orChars |= 0x5D;
11227 pos++;
11228 break;
11229 default:
11230 if (pos == _ps.charsUsed)
11231 {
11232 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11234 return _parseText_dummyTask;
11235 }
11236 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11238 return _parseText_dummyTask;
11239 }
11240 }
11241 }
11242
11243 private async Task<(int, int, int, bool)> ParseTextAsync_ParseEntity(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
11244 {
11245 int num;
11246 if ((num = ParseCharRefInline(pos, out var charCount, out var entityType)) > 0)
11247 {
11248 if (rcount > 0)
11249 {
11250 ShiftBuffer(rpos + rcount, rpos, pos - rpos - rcount);
11251 }
11252 rpos = pos - rcount;
11253 rcount += num - pos - charCount;
11254 pos = num;
11255 if (!XmlCharType.IsWhiteSpace(chars[num - charCount]) || (_v1Compat && entityType == EntityType.CharacterDec))
11256 {
11257 orChars |= 0xFF;
11258 }
11259 }
11260 else
11261 {
11262 if (pos > _ps.charPos)
11263 {
11264 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11267 }
11269 (pos, _) = tuple;
11270 switch (tuple.Item2)
11271 {
11272 case EntityType.Unexpanded:
11274 _parsingFunction = ParsingFunction.EntityReference;
11275 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11278 case EntityType.CharacterDec:
11279 if (_v1Compat)
11280 {
11281 orChars |= 0xFF;
11282 break;
11283 }
11284 goto case EntityType.CharacterHex;
11285 case EntityType.CharacterHex:
11286 case EntityType.CharacterNamed:
11287 if (!XmlCharType.IsWhiteSpace(_ps.chars[pos - 1]))
11288 {
11289 orChars |= 0xFF;
11290 }
11291 break;
11292 default:
11293 pos = _ps.charPos;
11294 break;
11295 }
11296 chars = _ps.chars;
11297 }
11298 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11301 }
11302
11303 private async Task<(int, int, int, bool)> ParseTextAsync_Surrogate(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
11304 {
11305 char c2 = chars[pos];
11307 {
11308 if (pos + 1 == _ps.charsUsed)
11309 {
11310 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11313 }
11314 pos++;
11316 {
11317 pos++;
11318 orChars |= c2;
11319 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11322 }
11323 }
11324 int offset = pos - _ps.charPos;
11325 if (await ZeroEndingStreamAsync(pos).ConfigureAwait(continueOnCapturedContext: false))
11326 {
11327 chars = _ps.chars;
11328 pos = _ps.charPos + offset;
11329 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11332 }
11335 }
11336
11337 private async Task<(int, int, int, bool)> ParseTextAsync_ReadData(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
11338 {
11339 if (pos > _ps.charPos)
11340 {
11341 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11344 }
11345 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
11346 {
11347 if (_ps.charsUsed - _ps.charPos > 0)
11348 {
11349 if (_ps.chars[_ps.charPos] != '\r' && _ps.chars[_ps.charPos] != ']')
11350 {
11352 }
11353 }
11354 else
11355 {
11356 if (!InEntity)
11357 {
11358 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11361 }
11363 {
11365 _parsingFunction = ParsingFunction.ReportEndEntity;
11366 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11369 }
11370 }
11371 }
11372 pos = _ps.charPos;
11373 chars = _ps.chars;
11374 _lastParseTextState = new ParseTextState(outOrChars, chars, pos, rcount, rpos, orChars, c);
11377 }
11378
11379 private (int, int, int, bool) ParseText_NoValue(int outOrChars, int pos)
11380 {
11381 return (pos, pos, outOrChars, true);
11382 }
11383
11384 private (int, int, int, bool) ParseText_PartialValue(int pos, int rcount, int rpos, int orChars, char c)
11385 {
11386 if (_parsingMode == ParsingMode.Full && rcount > 0)
11387 {
11388 ShiftBuffer(rpos + rcount, rpos, pos - rpos - rcount);
11389 }
11390 int charPos = _ps.charPos;
11391 int item = pos - rcount;
11392 _ps.charPos = pos;
11393 return (charPos, item, orChars, c == '<');
11394 }
11395
11397 {
11399 int outOrChars = 0;
11401 int num;
11402 int num2;
11403 (num, num2, outOrChars, _) = tuple;
11404 while (!tuple.Item4)
11405 {
11406 _stringBuilder.Append(_ps.chars, num, num2 - num);
11408 (num, num2, outOrChars, _) = tuple;
11409 }
11410 _stringBuilder.Append(_ps.chars, num, num2 - num);
11413 }
11414
11416 {
11417 switch (_parsingFunction)
11418 {
11419 case ParsingFunction.InReadValueChunk:
11420 if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue)
11421 {
11423 _incReadState = IncrementalReadState.ReadValueChunk_OnCachedValue;
11424 }
11425 else if (_readValueOffset > 0)
11426 {
11428 _readValueOffset = 0;
11429 }
11430 break;
11431 case ParsingFunction.InReadContentAsBinary:
11432 case ParsingFunction.InReadElementContentAsBinary:
11433 switch (_incReadState)
11434 {
11435 case IncrementalReadState.ReadContentAsBinary_OnPartialValue:
11437 _incReadState = IncrementalReadState.ReadContentAsBinary_OnCachedValue;
11438 break;
11439 case IncrementalReadState.ReadContentAsBinary_OnCachedValue:
11440 if (_readValueOffset > 0)
11441 {
11443 _readValueOffset = 0;
11444 }
11445 break;
11446 case IncrementalReadState.ReadContentAsBinary_End:
11447 _curNode.SetValue(string.Empty);
11448 break;
11449 }
11450 break;
11451 case ParsingFunction.InReadAttributeValue:
11452 break;
11453 }
11454 }
11455
11456 [MethodImpl(MethodImplOptions.NoInlining)]
11458 {
11459 int outOrChars = 0;
11461 (int, int, int, bool) tuple;
11462 do
11463 {
11465 outOrChars = tuple.Item3;
11466 }
11467 while (!tuple.Item4);
11468 }
11469
11471 {
11472 _readValueOffset = 0;
11473 if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue)
11474 {
11476 }
11479 return Task.CompletedTask;
11480 }
11481
11483 {
11484 _readValueOffset = 0;
11485 if (_incReadState == IncrementalReadState.ReadContentAsBinary_OnPartialValue)
11486 {
11488 }
11489 else
11490 {
11493 }
11494 if (_incReadState != IncrementalReadState.ReadContentAsBinary_End)
11495 {
11497 {
11498 }
11499 }
11500 }
11501
11503 {
11505 if (_curNode.type != XmlNodeType.EndElement)
11506 {
11508 }
11509 await _outerReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
11510 }
11511
11513 {
11514 XmlNodeType nodeType = GetWhitespaceType();
11515 if (nodeType == XmlNodeType.None)
11516 {
11517 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
11518 bool flag = _ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0;
11519 bool flag2 = flag;
11520 if (!flag2)
11521 {
11523 }
11524 if (flag2)
11525 {
11526 return false;
11527 }
11528 }
11529 else
11530 {
11533 bool flag3 = _ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0;
11534 bool flag4 = flag3;
11535 if (!flag4)
11536 {
11538 }
11539 if (flag4)
11540 {
11541 if (_stringBuilder.Length > 0)
11542 {
11545 return true;
11546 }
11547 return false;
11548 }
11549 }
11551 {
11553 }
11554 else
11555 {
11557 }
11558 return false;
11559 }
11560
11562 {
11563 _ps.charPos++;
11565 NodeData curNode = _curNode;
11566 curNode.SetNamedNode(XmlNodeType.EntityReference, await ParseEntityNameAsync().ConfigureAwait(continueOnCapturedContext: false));
11567 }
11568
11570 {
11571 if (_ps.charPos + 1 == _ps.charsUsed && await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
11572 {
11574 }
11575 int charRefEndPos;
11576 if (_ps.chars[_ps.charPos + 1] == '#')
11577 {
11580 return (charRefEndPos, item);
11581 }
11583 if (charRefEndPos >= 0)
11584 {
11585 return (charRefEndPos, EntityType.CharacterNamed);
11586 }
11588 {
11589 return (charRefEndPos, EntityType.Unexpanded);
11590 }
11591 _ps.charPos++;
11592 int savedLinePos = _ps.LinePos;
11593 int num;
11594 try
11595 {
11596 num = await ParseNameAsync().ConfigureAwait(continueOnCapturedContext: false);
11597 }
11598 catch (XmlException)
11599 {
11601 return (charRefEndPos, EntityType.Skipped);
11602 }
11603 if (_ps.chars[num] != ';')
11604 {
11605 ThrowUnexpectedToken(num, ";");
11606 }
11607 int linePos = _ps.LinePos;
11608 string name = _nameTable.Add(_ps.chars, _ps.charPos, num - _ps.charPos);
11609 _ps.charPos = num + 1;
11610 charRefEndPos = -1;
11614 return (charRefEndPos, item2);
11615 }
11616
11618 {
11619 IDtdEntityInfo entity = null;
11621 {
11623 }
11624 if (_dtdInfo != null)
11625 {
11627 entity = (dtdEntityInfo = _dtdInfo.LookupEntity(name));
11628 if (dtdEntityInfo != null)
11629 {
11630 goto IL_012e;
11631 }
11632 }
11634 {
11636 schemaEntity.Text = string.Empty;
11637 entity = schemaEntity;
11638 }
11639 else
11640 {
11642 }
11643 goto IL_012e;
11644 IL_012e:
11645 if (entity.IsUnparsedEntity)
11646 {
11648 {
11650 schemaEntity2.Text = string.Empty;
11651 entity = schemaEntity2;
11652 }
11653 else
11654 {
11656 }
11657 }
11658 if (_standalone && entity.IsDeclaredInExternal)
11659 {
11661 }
11662 if (entity.IsExternal)
11663 {
11665 {
11667 return EntityType.Skipped;
11668 }
11669 if (_parsingMode == ParsingMode.SkipContent)
11670 {
11671 return EntityType.Skipped;
11672 }
11673 if (IsResolverNull)
11674 {
11676 {
11677 await PushExternalEntityAsync(entity).ConfigureAwait(continueOnCapturedContext: false);
11679 return EntityType.FakeExpanded;
11680 }
11681 return EntityType.Skipped;
11682 }
11683 await PushExternalEntityAsync(entity).ConfigureAwait(continueOnCapturedContext: false);
11686 }
11687 if (_parsingMode == ParsingMode.SkipContent)
11688 {
11689 return EntityType.Skipped;
11690 }
11691 PushInternalEntity(entity);
11694 }
11695
11697 {
11698 return ParsePIAsync(null);
11699 }
11700
11702 {
11703 if (_parsingMode == ParsingMode.Full)
11704 {
11706 }
11707 int num = await ParseNameAsync().ConfigureAwait(continueOnCapturedContext: false);
11708 string text = _nameTable.Add(_ps.chars, _ps.charPos, num - _ps.charPos);
11709 if (string.Equals(text, "xml", StringComparison.OrdinalIgnoreCase))
11710 {
11712 }
11713 _ps.charPos = num;
11714 if (piInDtdStringBuilder == null)
11715 {
11716 if (!_ignorePIs && _parsingMode == ParsingMode.Full)
11717 {
11718 _curNode.SetNamedNode(XmlNodeType.ProcessingInstruction, text);
11719 }
11720 }
11721 else
11722 {
11723 piInDtdStringBuilder.Append(text);
11724 }
11725 char ch = _ps.chars[_ps.charPos];
11727 {
11728 if (_ps.charsUsed - _ps.charPos < 2)
11729 {
11730 await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false);
11731 }
11732 if (ch != '?' || _ps.chars[_ps.charPos + 1] != '>')
11733 {
11735 }
11736 }
11737 (int, int, bool) tuple = await ParsePIValueAsync().ConfigureAwait(continueOnCapturedContext: false);
11738 var (num2, num3, _) = tuple;
11739 if (tuple.Item3)
11740 {
11741 if (piInDtdStringBuilder == null)
11742 {
11743 if (_ignorePIs)
11744 {
11745 return false;
11746 }
11747 if (_parsingMode == ParsingMode.Full)
11748 {
11750 }
11751 }
11752 else
11753 {
11755 }
11756 }
11757 else
11758 {
11759 StringBuilder sb;
11760 if (piInDtdStringBuilder == null)
11761 {
11762 if (_ignorePIs || _parsingMode != 0)
11763 {
11764 (int, int, bool) tuple3;
11765 do
11766 {
11767 tuple3 = await ParsePIValueAsync().ConfigureAwait(continueOnCapturedContext: false);
11768 _ = tuple3.Item1;
11769 _ = tuple3.Item2;
11770 }
11771 while (!tuple3.Item3);
11772 return false;
11773 }
11774 sb = _stringBuilder;
11775 }
11776 else
11777 {
11779 }
11780 (int, int, bool) tuple4;
11781 do
11782 {
11783 sb.Append(_ps.chars, num2, num3 - num2);
11784 tuple4 = await ParsePIValueAsync().ConfigureAwait(continueOnCapturedContext: false);
11785 (num2, num3, _) = tuple4;
11786 }
11787 while (!tuple4.Item3);
11788 sb.Append(_ps.chars, num2, num3 - num2);
11789 if (piInDtdStringBuilder == null)
11790 {
11793 }
11794 }
11795 return true;
11796 }
11797
11799 {
11800 if (_ps.charsUsed - _ps.charPos < 2 && await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
11801 {
11803 }
11804 int num = _ps.charPos;
11805 char[] chars = _ps.chars;
11806 int num2 = 0;
11807 int num3 = -1;
11808 int item;
11809 int charPos;
11810 while (true)
11811 {
11812 char c;
11813 if (XmlCharType.IsTextChar(c = chars[num]) && c != '?')
11814 {
11815 num++;
11816 continue;
11817 }
11818 switch (chars[num])
11819 {
11820 case '?':
11821 if (chars[num + 1] == '>')
11822 {
11823 if (num2 > 0)
11824 {
11825 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
11826 item = num - num2;
11827 }
11828 else
11829 {
11830 item = num;
11831 }
11832 charPos = _ps.charPos;
11833 _ps.charPos = num + 2;
11834 return (charPos, item, true);
11835 }
11836 if (num + 1 != _ps.charsUsed)
11837 {
11838 num++;
11839 continue;
11840 }
11841 break;
11842 case '\n':
11843 num++;
11844 OnNewLine(num);
11845 continue;
11846 case '\r':
11847 if (chars[num + 1] == '\n')
11848 {
11849 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
11850 {
11851 if (num - _ps.charPos > 0)
11852 {
11853 if (num2 == 0)
11854 {
11855 num2 = 1;
11856 num3 = num;
11857 }
11858 else
11859 {
11860 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
11861 num3 = num - num2;
11862 num2++;
11863 }
11864 }
11865 else
11866 {
11867 _ps.charPos++;
11868 }
11869 }
11870 num += 2;
11871 }
11872 else
11873 {
11874 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
11875 {
11876 break;
11877 }
11878 if (!_ps.eolNormalized)
11879 {
11880 chars[num] = '\n';
11881 }
11882 num++;
11883 }
11884 OnNewLine(num);
11885 continue;
11886 case '\t':
11887 case '&':
11888 case '<':
11889 case ']':
11890 num++;
11891 continue;
11892 default:
11893 {
11894 if (num == _ps.charsUsed)
11895 {
11896 break;
11897 }
11898 char ch = chars[num];
11900 {
11901 if (num + 1 == _ps.charsUsed)
11902 {
11903 break;
11904 }
11905 num++;
11907 {
11908 num++;
11909 continue;
11910 }
11911 }
11913 continue;
11914 }
11915 }
11916 break;
11917 }
11918 if (num2 > 0)
11919 {
11920 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
11921 item = num - num2;
11922 }
11923 else
11924 {
11925 item = num;
11926 }
11927 charPos = _ps.charPos;
11928 _ps.charPos = num;
11929 return (charPos, item, false);
11930 }
11931
11933 {
11934 if (_ignoreComments)
11935 {
11937 _parsingMode = ParsingMode.SkipNode;
11940 return false;
11941 }
11943 return true;
11944 }
11945
11947 {
11949 }
11950
11952 {
11953 if (_parsingMode == ParsingMode.Full)
11954 {
11957 var (num, num2, _) = tuple;
11958 if (tuple.Item3)
11959 {
11960 _curNode.SetValueNode(type, _ps.chars, num, num2 - num);
11961 return;
11962 }
11963 (int, int, bool) tuple3;
11964 do
11965 {
11966 _stringBuilder.Append(_ps.chars, num, num2 - num);
11968 (num, num2, _) = tuple3;
11969 }
11970 while (!tuple3.Item3);
11971 _stringBuilder.Append(_ps.chars, num, num2 - num);
11974 }
11975 else
11976 {
11977 (int, int, bool) tuple5;
11978 do
11979 {
11981 _ = tuple5.Item1;
11982 _ = tuple5.Item2;
11983 }
11984 while (!tuple5.Item3);
11985 }
11986 }
11987
11989 {
11990 if (_ps.charsUsed - _ps.charPos < 3 && await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
11991 {
11992 Throw(System.SR.Xml_UnexpectedEOF, (type == XmlNodeType.Comment) ? "Comment" : "CDATA");
11993 }
11994 int num = _ps.charPos;
11995 char[] chars = _ps.chars;
11996 int num2 = 0;
11997 int num3 = -1;
11998 char c = ((type == XmlNodeType.Comment) ? '-' : ']');
11999 int item;
12000 int charPos;
12001 while (true)
12002 {
12003 char c2;
12004 if (XmlCharType.IsTextChar(c2 = chars[num]) && c2 != c)
12005 {
12006 num++;
12007 continue;
12008 }
12009 if (chars[num] == c)
12010 {
12011 if (chars[num + 1] == c)
12012 {
12013 if (chars[num + 2] == '>')
12014 {
12015 if (num2 > 0)
12016 {
12017 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
12018 item = num - num2;
12019 }
12020 else
12021 {
12022 item = num;
12023 }
12024 charPos = _ps.charPos;
12025 _ps.charPos = num + 3;
12026 return (charPos, item, true);
12027 }
12028 if (num + 2 == _ps.charsUsed)
12029 {
12030 break;
12031 }
12032 if (type == XmlNodeType.Comment)
12033 {
12035 }
12036 }
12037 else if (num + 1 == _ps.charsUsed)
12038 {
12039 break;
12040 }
12041 num++;
12042 continue;
12043 }
12044 switch (chars[num])
12045 {
12046 case '\n':
12047 num++;
12048 OnNewLine(num);
12049 continue;
12050 case '\r':
12051 if (chars[num + 1] == '\n')
12052 {
12053 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
12054 {
12055 if (num - _ps.charPos > 0)
12056 {
12057 if (num2 == 0)
12058 {
12059 num2 = 1;
12060 num3 = num;
12061 }
12062 else
12063 {
12064 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
12065 num3 = num - num2;
12066 num2++;
12067 }
12068 }
12069 else
12070 {
12071 _ps.charPos++;
12072 }
12073 }
12074 num += 2;
12075 }
12076 else
12077 {
12078 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
12079 {
12080 break;
12081 }
12082 if (!_ps.eolNormalized)
12083 {
12084 chars[num] = '\n';
12085 }
12086 num++;
12087 }
12088 OnNewLine(num);
12089 continue;
12090 case '\t':
12091 case '&':
12092 case '<':
12093 case ']':
12094 num++;
12095 continue;
12096 default:
12097 {
12098 if (num == _ps.charsUsed)
12099 {
12100 break;
12101 }
12102 char ch = chars[num];
12104 {
12105 if (num + 1 == _ps.charsUsed)
12106 {
12107 break;
12108 }
12109 num++;
12111 {
12112 num++;
12113 continue;
12114 }
12115 }
12117 break;
12118 }
12119 }
12120 break;
12121 }
12122 if (num2 > 0)
12123 {
12124 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
12125 item = num - num2;
12126 }
12127 else
12128 {
12129 item = num;
12130 }
12131 charPos = _ps.charPos;
12132 _ps.charPos = num;
12133 return (charPos, item, false);
12134 }
12135
12137 {
12138 if (_dtdProcessing == DtdProcessing.Prohibit)
12139 {
12141 }
12142 while (_ps.charsUsed - _ps.charPos < 8)
12143 {
12144 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
12145 {
12146 Throw(System.SR.Xml_UnexpectedEOF, "DOCTYPE");
12147 }
12148 }
12149 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, 7, "DOCTYPE"))
12150 {
12151 ThrowUnexpectedToken((!_rootElementParsed && _dtdInfo == null) ? "DOCTYPE" : "<!--");
12152 }
12154 {
12156 }
12157 if (_dtdInfo != null)
12158 {
12160 }
12162 {
12164 }
12165 _ps.charPos += 8;
12166 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
12167 if (_dtdProcessing == DtdProcessing.Parse)
12168 {
12170 await ParseDtdAsync().ConfigureAwait(continueOnCapturedContext: false);
12172 _parsingFunction = ParsingFunction.ResetAttributesRootLevel;
12173 return true;
12174 }
12175 await SkipDtdAsync().ConfigureAwait(continueOnCapturedContext: false);
12176 return false;
12177 }
12178
12180 {
12182 _dtdInfo = await dtdParser.ParseInternalDtdAsync(new DtdParserProxy(this), saveInternalSubset: true).ConfigureAwait(continueOnCapturedContext: false);
12184 {
12186 }
12187 _curNode.SetNamedNode(XmlNodeType.DocumentType, _dtdInfo.Name.ToString(), string.Empty, null);
12189 }
12190
12192 {
12193 (int, int) tuple = await ParseQNameAsync().ConfigureAwait(continueOnCapturedContext: false);
12194 _ = tuple.Item1;
12195 int item = tuple.Item2;
12196 _ps.charPos = item;
12197 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
12198 if (_ps.chars[_ps.charPos] == 'P')
12199 {
12200 while (_ps.charsUsed - _ps.charPos < 6)
12201 {
12202 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
12203 {
12205 }
12206 }
12207 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, 6, "PUBLIC"))
12208 {
12209 ThrowUnexpectedToken("PUBLIC");
12210 }
12211 _ps.charPos += 6;
12212 if (await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false) == 0)
12213 {
12215 }
12217 if (await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false) == 0)
12218 {
12220 }
12222 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
12223 }
12224 else if (_ps.chars[_ps.charPos] == 'S')
12225 {
12226 while (_ps.charsUsed - _ps.charPos < 6)
12227 {
12228 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
12229 {
12231 }
12232 }
12233 if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, 6, "SYSTEM"))
12234 {
12235 ThrowUnexpectedToken("SYSTEM");
12236 }
12237 _ps.charPos += 6;
12238 if (await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false) == 0)
12239 {
12241 }
12243 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
12244 }
12245 else if (_ps.chars[_ps.charPos] != '[' && _ps.chars[_ps.charPos] != '>')
12246 {
12248 }
12249 if (_ps.chars[_ps.charPos] == '[')
12250 {
12251 _ps.charPos++;
12252 await SkipUntilAsync(']', recognizeLiterals: true).ConfigureAwait(continueOnCapturedContext: false);
12253 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
12254 if (_ps.chars[_ps.charPos] != '>')
12255 {
12257 }
12258 }
12259 else if (_ps.chars[_ps.charPos] == '>')
12260 {
12261 _curNode.SetValue(string.Empty);
12262 }
12263 else
12264 {
12266 }
12267 _ps.charPos++;
12268 }
12269
12271 {
12272 char c = _ps.chars[_ps.charPos];
12273 if (c != '"' && c != '\'')
12274 {
12275 ThrowUnexpectedToken("\"", "'");
12276 }
12277 _ps.charPos++;
12278 return SkipUntilAsync(c, recognizeLiterals: false);
12279 }
12280
12282 {
12283 bool inLiteral = false;
12284 bool inComment = false;
12285 bool inPI = false;
12286 char literalQuote = '"';
12287 char[] chars = _ps.chars;
12288 int num = _ps.charPos;
12289 while (true)
12290 {
12291 char c;
12292 if (XmlCharType.IsAttributeValueChar(c = chars[num]) && c != stopChar && c != '-' && c != '?')
12293 {
12294 num++;
12295 continue;
12296 }
12297 if (c == stopChar && !inLiteral)
12298 {
12299 break;
12300 }
12301 _ps.charPos = num;
12302 switch (c)
12303 {
12304 case '\n':
12305 num++;
12306 OnNewLine(num);
12307 continue;
12308 case '\r':
12309 if (chars[num + 1] == '\n')
12310 {
12311 num += 2;
12312 }
12313 else
12314 {
12315 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
12316 {
12317 break;
12318 }
12319 num++;
12320 }
12321 OnNewLine(num);
12322 continue;
12323 case '<':
12324 if (chars[num + 1] == '?')
12325 {
12327 {
12328 inPI = true;
12329 num += 2;
12330 continue;
12331 }
12332 }
12333 else if (chars[num + 1] == '!')
12334 {
12335 if (num + 3 >= _ps.charsUsed && !_ps.isEof)
12336 {
12337 break;
12338 }
12339 if (chars[num + 2] == '-' && chars[num + 3] == '-' && recognizeLiterals && !inLiteral && !inPI)
12340 {
12341 inComment = true;
12342 num += 4;
12343 continue;
12344 }
12345 }
12346 else if (num + 1 >= _ps.charsUsed && !_ps.isEof)
12347 {
12348 break;
12349 }
12350 num++;
12351 continue;
12352 case '-':
12353 if (inComment)
12354 {
12355 if (num + 2 >= _ps.charsUsed && !_ps.isEof)
12356 {
12357 break;
12358 }
12359 if (chars[num + 1] == '-' && chars[num + 2] == '>')
12360 {
12361 inComment = false;
12362 num += 2;
12363 continue;
12364 }
12365 }
12366 num++;
12367 continue;
12368 case '?':
12369 if (inPI)
12370 {
12371 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
12372 {
12373 break;
12374 }
12375 if (chars[num + 1] == '>')
12376 {
12377 inPI = false;
12378 num++;
12379 continue;
12380 }
12381 }
12382 num++;
12383 continue;
12384 case '\t':
12385 case '&':
12386 case '>':
12387 case ']':
12388 num++;
12389 continue;
12390 case '"':
12391 case '\'':
12392 if (inLiteral)
12393 {
12394 if (literalQuote == c)
12395 {
12396 inLiteral = false;
12397 }
12398 }
12399 else if (recognizeLiterals && !inComment && !inPI)
12400 {
12401 inLiteral = true;
12402 literalQuote = c;
12403 }
12404 num++;
12405 continue;
12406 default:
12407 {
12408 if (num == _ps.charsUsed)
12409 {
12410 break;
12411 }
12412 char ch = chars[num];
12414 {
12415 if (num + 1 == _ps.charsUsed)
12416 {
12417 break;
12418 }
12419 num++;
12421 {
12422 num++;
12423 continue;
12424 }
12425 }
12427 break;
12428 }
12429 }
12430 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
12431 {
12432 if (_ps.charsUsed - _ps.charPos > 0)
12433 {
12434 if (_ps.chars[_ps.charPos] != '\r')
12435 {
12437 }
12438 }
12439 else
12440 {
12442 }
12443 }
12444 chars = _ps.chars;
12445 num = _ps.charPos;
12446 }
12447 _ps.charPos = num + 1;
12448 }
12449
12451 {
12452 int num = _ps.charPos;
12453 int wsCount = 0;
12454 char[] chars = _ps.chars;
12455 while (true)
12456 {
12457 switch (chars[num])
12458 {
12459 case '\n':
12460 num++;
12461 OnNewLine(num);
12462 continue;
12463 case '\r':
12464 if (chars[num + 1] == '\n')
12465 {
12466 int num3 = num - _ps.charPos;
12467 if (sb != null && !_ps.eolNormalized)
12468 {
12469 if (num3 > 0)
12470 {
12471 sb.Append(chars, _ps.charPos, num3);
12472 wsCount += num3;
12473 }
12474 _ps.charPos = num + 1;
12475 }
12476 num += 2;
12477 }
12478 else
12479 {
12480 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
12481 {
12482 break;
12483 }
12484 if (!_ps.eolNormalized)
12485 {
12486 chars[num] = '\n';
12487 }
12488 num++;
12489 }
12490 OnNewLine(num);
12491 continue;
12492 case '\t':
12493 case ' ':
12494 num++;
12495 continue;
12496 default:
12497 if (num != _ps.charsUsed)
12498 {
12499 int num2 = num - _ps.charPos;
12500 if (num2 > 0)
12501 {
12502 sb?.Append(_ps.chars, _ps.charPos, num2);
12503 _ps.charPos = num;
12504 wsCount += num2;
12505 }
12506 return wsCount;
12507 }
12508 break;
12509 }
12510 int num4 = num - _ps.charPos;
12511 if (num4 > 0)
12512 {
12513 sb?.Append(_ps.chars, _ps.charPos, num4);
12514 _ps.charPos = num;
12515 wsCount += num4;
12516 }
12517 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
12518 {
12519 if (_ps.charsUsed - _ps.charPos == 0)
12520 {
12521 break;
12522 }
12523 if (_ps.chars[_ps.charPos] != '\r')
12524 {
12526 }
12527 }
12528 num = _ps.charPos;
12529 chars = _ps.chars;
12530 }
12531 return wsCount;
12532 }
12533
12535 {
12536 int num;
12537 int charCount;
12539 while (true)
12540 {
12542 if (num2 != -2)
12543 {
12544 break;
12545 }
12546 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
12547 {
12549 }
12550 }
12551 if (expand)
12552 {
12553 _ps.charPos = num - charCount;
12554 }
12555 return (entityType, num);
12556 }
12557
12559 {
12560 do
12561 {
12562 int num;
12564 {
12565 case -1:
12566 return -1;
12567 case -2:
12568 continue;
12569 }
12570 if (expand)
12571 {
12572 _ps.charPos = num - 1;
12573 }
12574 return num;
12575 }
12576 while (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) != 0);
12577 return -1;
12578 }
12579
12581 {
12582 return (await ParseQNameAsync(isQName: false, 0).ConfigureAwait(continueOnCapturedContext: false)).Item2;
12583 }
12584
12586 {
12587 return ParseQNameAsync(isQName: true, 0);
12588 }
12589
12591 {
12592 int colonOffset = -1;
12593 int num = _ps.charPos + startOffset;
12594 while (true)
12595 {
12596 char[] chars = _ps.chars;
12598 {
12599 num++;
12600 }
12601 else if (num + 1 >= _ps.charsUsed)
12602 {
12603 (int, bool) tuple = await ReadDataInNameAsync(num).ConfigureAwait(continueOnCapturedContext: false);
12604 (num, _) = tuple;
12605 if (tuple.Item2)
12606 {
12607 continue;
12608 }
12609 Throw(num, System.SR.Xml_UnexpectedEOF, "Name");
12610 }
12611 else if (chars[num] != ':' || _supportNamespaces)
12612 {
12614 }
12615 while (true)
12616 {
12618 {
12619 num++;
12620 continue;
12621 }
12622 if (chars[num] == ':')
12623 {
12625 {
12626 break;
12627 }
12628 colonOffset = num - _ps.charPos;
12629 num++;
12630 continue;
12631 }
12632 if (num == _ps.charsUsed)
12633 {
12634 (int, bool) tuple3 = await ReadDataInNameAsync(num).ConfigureAwait(continueOnCapturedContext: false);
12635 (num, _) = tuple3;
12636 if (tuple3.Item2)
12637 {
12638 chars = _ps.chars;
12639 continue;
12640 }
12641 Throw(num, System.SR.Xml_UnexpectedEOF, "Name");
12642 }
12643 int item = ((colonOffset == -1) ? (-1) : (_ps.charPos + colonOffset));
12644 return (item, num);
12645 }
12646 if (colonOffset != -1 || !isQName)
12647 {
12649 }
12650 colonOffset = num - _ps.charPos;
12651 num++;
12652 }
12653 }
12654
12656 {
12657 int offset = pos - _ps.charPos;
12658 bool item = await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) != 0;
12659 pos = _ps.charPos + offset;
12660 return (pos, item);
12661 }
12662
12664 {
12665 int num;
12666 try
12667 {
12668 num = await ParseNameAsync().ConfigureAwait(continueOnCapturedContext: false);
12669 }
12670 catch (XmlException)
12671 {
12673 return null;
12674 }
12675 if (_ps.chars[num] != ';')
12676 {
12678 }
12679 string result = _nameTable.Add(_ps.chars, _ps.charPos, num - _ps.charPos);
12680 _ps.charPos = num + 1;
12681 return result;
12682 }
12683
12684 private async Task PushExternalEntityOrSubsetAsync(string publicId, string systemId, Uri baseUri, string entityName)
12685 {
12686 Uri uri;
12687 if (!string.IsNullOrEmpty(publicId))
12688 {
12689 try
12690 {
12691 uri = _xmlResolver.ResolveUri(baseUri, publicId);
12692 if (await OpenAndPushAsync(uri).ConfigureAwait(continueOnCapturedContext: false))
12693 {
12694 return;
12695 }
12696 }
12697 catch (Exception)
12698 {
12699 }
12700 }
12701 uri = _xmlResolver.ResolveUri(baseUri, systemId);
12702 try
12703 {
12704 if (await OpenAndPushAsync(uri).ConfigureAwait(continueOnCapturedContext: false))
12705 {
12706 return;
12707 }
12708 }
12709 catch (Exception ex2)
12710 {
12711 if (_v1Compat)
12712 {
12713 throw;
12714 }
12715 string message = ex2.Message;
12717 {
12718 uri.ToString(),
12719 message
12720 }, ex2, 0, 0));
12721 }
12722 if (entityName == null)
12723 {
12725 {
12726 (publicId != null) ? publicId : string.Empty,
12727 systemId
12728 }, null);
12729 }
12730 else
12731 {
12733 }
12734 }
12735
12737 {
12739 {
12740 TextReader textReader = (TextReader)(await _xmlResolver.GetEntityAsync(uri, null, typeof(TextReader)).ConfigureAwait(continueOnCapturedContext: false));
12741 if (textReader == null)
12742 {
12743 return false;
12744 }
12747 }
12748 else
12749 {
12751 if (stream == null)
12752 {
12753 return false;
12754 }
12757 }
12758 return true;
12759 }
12760
12762 {
12763 if (!IsResolverNull)
12764 {
12765 Uri baseUri = null;
12766 if (!string.IsNullOrEmpty(entity.BaseUriString))
12767 {
12768 baseUri = _xmlResolver.ResolveUri(null, entity.BaseUriString);
12769 }
12770 await PushExternalEntityOrSubsetAsync(entity.PublicId, entity.SystemId, baseUri, entity.Name).ConfigureAwait(continueOnCapturedContext: false);
12771 RegisterEntity(entity);
12772 int initialPos = _ps.charPos;
12773 if (_v1Compat)
12774 {
12775 await EatWhitespacesAsync(null).ConfigureAwait(continueOnCapturedContext: false);
12776 }
12777 if (!(await ParseXmlDeclarationAsync(isTextDecl: true).ConfigureAwait(continueOnCapturedContext: false)))
12778 {
12780 }
12781 return true;
12782 }
12783 Encoding encoding = _ps.encoding;
12785 InitStringInput(entity.SystemId, encoding, string.Empty);
12786 RegisterEntity(entity);
12788 return false;
12789 }
12790
12792 {
12793 bool flag = _v1Compat && pos == _ps.charsUsed - 1 && _ps.chars[pos] == '\0';
12794 bool flag2 = flag;
12795 if (flag2)
12796 {
12797 flag2 = await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0;
12798 }
12799 if (flag2 && _ps.isStreamEof)
12800 {
12801 _ps.charsUsed--;
12802 return true;
12803 }
12804 return false;
12805 }
12806
12816
12818 {
12819 if (_parsingFunction == ParsingFunction.InReadValueChunk)
12820 {
12822 }
12823 if (_parsingFunction == ParsingFunction.InIncrementalRead)
12824 {
12826 }
12828 {
12829 return false;
12830 }
12831 SetupReadContentAsBinaryState(ParsingFunction.InReadContentAsBinary);
12833 return true;
12834 }
12835
12837 {
12839 await _outerReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
12840 if (isEmpty)
12841 {
12842 return false;
12843 }
12845 {
12846 if (_curNode.type != XmlNodeType.EndElement)
12847 {
12849 }
12850 await _outerReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
12851 return false;
12852 }
12853 SetupReadContentAsBinaryState(ParsingFunction.InReadElementContentAsBinary);
12855 return true;
12856 }
12857
12859 {
12860 do
12861 {
12862 switch (_curNode.type)
12863 {
12864 case XmlNodeType.Attribute:
12865 return !moveIfOnContentNode;
12866 case XmlNodeType.Text:
12867 case XmlNodeType.CDATA:
12868 case XmlNodeType.Whitespace:
12869 case XmlNodeType.SignificantWhitespace:
12871 {
12872 return true;
12873 }
12874 break;
12875 case XmlNodeType.EntityReference:
12877 break;
12878 default:
12879 return false;
12880 case XmlNodeType.ProcessingInstruction:
12881 case XmlNodeType.Comment:
12882 case XmlNodeType.EndEntity:
12883 break;
12884 }
12885 moveIfOnContentNode = false;
12886 }
12887 while (await _outerReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false));
12888 return false;
12889 }
12890
12892 {
12893 if (_incReadState == IncrementalReadState.ReadContentAsBinary_End)
12894 {
12895 return 0;
12896 }
12899 while (true)
12900 {
12901 int charsRead = 0;
12902 try
12903 {
12905 }
12906 catch (XmlException e)
12907 {
12910 }
12913 {
12915 }
12916 if (_incReadState == IncrementalReadState.ReadContentAsBinary_OnPartialValue)
12917 {
12918 _curNode.SetValue(string.Empty);
12919 bool flag = false;
12920 int num = 0;
12921 int num2 = 0;
12922 while (!_incReadDecoder.IsFull && !flag)
12923 {
12924 int outOrChars = 0;
12927 (num, num2, _, _) = tuple;
12928 _ = tuple.Item3;
12929 flag = tuple.Item4;
12930 try
12931 {
12933 }
12934 catch (XmlException e2)
12935 {
12937 }
12938 num += charsRead;
12939 }
12941 _readValueOffset = 0;
12943 {
12944 _curNode.SetValue(_ps.chars, num, num2 - num);
12948 }
12949 }
12954 {
12955 break;
12956 }
12959 }
12961 _incReadState = IncrementalReadState.ReadContentAsBinary_End;
12963 }
12964
12966 {
12967 if (count == 0)
12968 {
12969 return 0;
12970 }
12971 int num = await ReadContentAsBinaryAsync(buffer, index, count).ConfigureAwait(continueOnCapturedContext: false);
12972 if (num > 0)
12973 {
12974 return num;
12975 }
12976 if (_curNode.type != XmlNodeType.EndElement)
12977 {
12978 throw new XmlException(System.SR.Xml_InvalidNodeType, _curNode.type.ToString(), this);
12979 }
12982 await _outerReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
12983 return 0;
12984 }
12985}
static void Sort(Array array)
Definition Array.cs:2329
static int BinarySearch(Array array, object? value)
Definition Array.cs:1320
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
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
virtual string Message
Definition Exception.cs:100
static CultureInfo InvariantCulture
static int FromChar(int c)
int Read(byte[] buffer, int offset, int count)
void Dispose()
Definition Stream.cs:639
Task< int > ReadAsync(byte[] buffer, int offset, int count)
Definition Stream.cs:762
virtual int Read()
virtual Task< int > ReadAsync(char[] buffer, int index, int count)
static string Xml_BadAttributeChar
Definition SR.cs:74
static string Xml_TagMismatchEx
Definition SR.cs:68
static string Xml_ErrorOpeningExternalDtd
Definition SR.cs:168
static string Xml_CannotResolveEntity
Definition SR.cs:142
static string Xml_InvalidXmlSpace
Definition SR.cs:92
static string Xml_UnexpectedEOF1
Definition SR.cs:38
static string Xml_CharEntityOverflow
Definition SR.cs:208
static string Xml_ReaderAsyncNotSetException
Definition SR.cs:32
static string Xml_InvalidCommentChars
Definition SR.cs:288
static string Xml_PartialContentNodeTypeNotSupportedEx
Definition SR.cs:104
static string Xml_ExpectSubOrClose
Definition SR.cs:270
static string Xml_WhitespaceHandling
Definition SR.cs:224
static string Xml_DoubleBaseUri
Definition SR.cs:192
static string Xml_UnclosedQuote
Definition SR.cs:34
static string Xml_NotEnoughSpaceForSurrogatePair
Definition SR.cs:194
static string Xml_ExternalEntityInAttValue
Definition SR.cs:126
static string Xml_LimitExceeded
Definition SR.cs:204
static string Xml_MixingV1StreamingWithV2Binary
Definition SR.cs:186
static string Xml_BadStartNameChar
Definition SR.cs:42
static string Xml_InvalidReadValueChunk
Definition SR.cs:188
static string Xml_CannotResolveExternalSubset
Definition SR.cs:146
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Xml_InvalidXmlDecl
Definition SR.cs:86
static string Xml_EncodingSwitchAfterResetState
Definition SR.cs:234
static string Xml_UndeclaredEntity
Definition SR.cs:120
static string Xml_DtdIsProhibited
Definition SR.cs:158
static string Xml_BadDTDLocation
Definition SR.cs:98
static string Xml_MissingRoot
Definition SR.cs:78
static string Xml_InvalidCharInThisEncoding
Definition SR.cs:56
static string Xml_UnknownNs
Definition SR.cs:72
static string Xml_MultipleDTDsProvided
Definition SR.cs:106
static string Xml_InvalidPIName
Definition SR.cs:90
static string Sch_ParEntityRefNesting
Definition SR.cs:392
static string Xml_InvalidNodeType
Definition SR.cs:88
static string Xml_InvalidVersionNumber
Definition SR.cs:94
static string Xml_MixingBinaryContentMethods
Definition SR.cs:184
static string Xml_EntityRefNesting
Definition SR.cs:140
static string Xml_UnparsedEntityRef
Definition SR.cs:128
static string Xml_RecursiveParEntity
Definition SR.cs:122
static string Xml_MultipleRoots
Definition SR.cs:80
static string Xml_InternalError
Definition SR.cs:54
static string Xml_NamespaceDeclXmlXmlns
Definition SR.cs:308
static string Xml_UnknownEncoding
Definition SR.cs:52
static string Sch_UnSpecifiedDefaultAttributeInExternalStandalone
Definition SR.cs:400
static string Xml_MixingReadValueChunkWithBinary
Definition SR.cs:182
static string Xml_ExternalEntityInStandAloneDocument
Definition SR.cs:152
static string Xml_BadNamespaceDecl
Definition SR.cs:134
static string Xml_EmptyUrl
Definition SR.cs:196
static string Xml_BadDecimalEntity
Definition SR.cs:46
static string Xml_UnexpectedTokens2
Definition SR.cs:64
static string Xml_InvalidRootData
Definition SR.cs:82
static string Xml_InvalidCharacter
Definition SR.cs:110
static string Xml_DtdIsProhibitedEx
Definition SR.cs:160
static string Xml_UnexpectedTokenEx
Definition SR.cs:62
static string Xml_IncompleteEntity
Definition SR.cs:320
static string Xml_DefaultException
Definition SR.cs:16
static string Xml_InvalidResetStateCall
Definition SR.cs:226
static string Xml_UnexpectedEOFInElementContent
Definition SR.cs:40
static string Xml_NametableMismatch
Definition SR.cs:132
static string Xml_ExpectingWhiteSpace
Definition SR.cs:66
static string Xml_InvalidTextDecl
Definition SR.cs:116
static string Xml_InvalidOperation
Definition SR.cs:18
static string Xml_DupAttributeName
Definition SR.cs:96
static string Xml_ErrorParsingEntityName
Definition SR.cs:136
static string Xml_CannotResolveUrl
Definition SR.cs:148
static string Xml_CDATAEndInText
Definition SR.cs:150
static string Xml_BadNameChar
Definition SR.cs:44
static string Xml_EntityHandling
Definition SR.cs:228
static string Xml_UnexpectedEOF
Definition SR.cs:36
static string Xml_CannotResolveEntityDtdIgnored
Definition SR.cs:144
static string Xml_ErrorOpeningExternalEntity
Definition SR.cs:170
static string Sch_StandAloneNormalization
Definition SR.cs:398
static string Xml_MissingByteOrderMark
Definition SR.cs:50
static string Xml_BadHexEntity
Definition SR.cs:48
static string Xml_DtdAfterRootElement
Definition SR.cs:154
static string Xml_UnexpectedEndTag
Definition SR.cs:70
static string Xml_RecursiveGenEntity
Definition SR.cs:124
static string Xml_XmlDeclNotFirst
Definition SR.cs:84
static string Xml_ExpectExternalOrClose
Definition SR.cs:76
static string Xml_XmlnsPrefix
Definition SR.cs:306
Definition SR.cs:7
virtual void Convert(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
Definition Decoder.cs:142
static Encoding BigEndianUnicode
Definition Encoding.cs:521
static Encoding Unicode
Definition Encoding.cs:519
virtual ReadOnlySpan< byte > Preamble
Definition Encoding.cs:347
static Encoding UTF8
Definition Encoding.cs:526
static Encoding GetEncoding(int codepage)
Definition Encoding.cs:593
virtual string WebName
Definition Encoding.cs:386
virtual Decoder GetDecoder()
Definition Encoding.cs:1004
virtual int GetByteCount(char[] chars)
Definition Encoding.cs:713
override string ToString()
StringBuilder Append(char value, int repeatCount)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
static Task CompletedTask
Definition Task.cs:1120
override string ToString()
Definition Uri.cs:1119
static readonly Task< int > DoneTaskZero
static readonly Task< bool > DoneTaskTrue
Definition AsyncHelper.cs:7
static readonly Task< bool > DoneTaskFalse
Definition AsyncHelper.cs:9
static IDtdParser Create()
Definition DtdParser.cs:261
int Decode(char[] chars, int startPos, int len)
void SetNextOutputBuffer(Array array, int offset, int len)
static bool Equal(string strA, string strB)
Definition Ref.cs:5
static Encoding UCS4_Littleendian
static Encoding UCS4_2143
static Encoding UCS4_Bigendian
static Encoding UCS4_3412
static void SplitSurrogateChar(int combinedChar, out char lowChar, out char highChar)
static bool IsStartNCNameSingleChar(char ch)
static bool IsAttributeValueChar(char ch)
static bool IsNCNameSingleChar(char ch)
static bool IsWhiteSpace(char ch)
static bool IsTextChar(char ch)
static bool IsLowSurrogate(int ch)
static bool IsNameSingleChar(char ch)
static bool IsCharData(char ch)
static bool IsHighSurrogate(int ch)
static string TrimString(string value)
static bool StrEqual(char[] chars, int strPos1, int strLen1, string str2)
static string[] BuildCharExceptionArgs(string data, int invCharIndex)
string Add(char[] array, int offset, int length)
string? Get(char[] array, int offset, int length)
virtual ? string LookupNamespace(string prefix)
virtual ? string LookupPrefix(string uri)
virtual IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
virtual void AddNamespace(string prefix, string uri)
XmlNamespaceManager? NamespaceManager
static bool IsTextualNode(XmlNodeType nodeType)
Exception CreateReadElementContentAsException(string methodName)
virtual bool CanResolveEntity
Definition XmlReader.cs:118
Exception CreateReadContentAsException(string methodName)
static bool HasValueInternal(XmlNodeType nodeType)
static int CalcBufferSize(Stream input)
virtual ? IDtdInfo DtdInfo
Definition XmlReader.cs:145
virtual Task< bool > ReadAsync()
virtual string XmlLang
Definition XmlReader.cs:98
XmlNodeType NodeType
Definition XmlReader.cs:62
static bool CanReadContentAs(XmlNodeType nodeType)
XmlNameTable NameTable
Definition XmlReader.cs:116
virtual bool CanReadValueChunk
Definition XmlReader.cs:122
virtual bool CanReadBinaryContent
Definition XmlReader.cs:120
object? GetEntity(Uri absoluteUri, string? role, Type? ofObjectToReturn)
virtual bool SupportsType(Uri absoluteUri, Type? type)
virtual Task< object > GetEntityAsync(Uri absoluteUri, string? role, Type? ofObjectToReturn)
virtual Uri ResolveUri(Uri? baseUri, string? relativeUri)
override void RemoveNamespace(string prefix, string uri)
override void AddNamespace(string prefix, string uri)
override IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
void SetNamedNode(XmlNodeType type, string localName, string prefix, string nameWPrefix)
void SetValue(char[] chars, int startPos, int len)
int CopyTo(int valueOffset, char[] buffer, int offset, int length)
int CopyToBinary(IncrementalReadDecoder decoder, int valueOffset)
void SetLineInfo(int lineNo, int linePos)
void SetNamedNode(XmlNodeType type, string localName)
void CopyTo(int valueOffset, StringBuilder sb)
void SetValueNode(XmlNodeType type, char[] chars, int startPos, int len)
void SetLineInfo2(int lineNo, int linePos)
void SetValueNode(XmlNodeType type, string value)
void AdjustLineInfo(int valueOffset, bool isNormalized, ref LineInfo lineInfo)
async Task< int > ReadContentAsBase64_AsyncHelper(Task< bool > task, byte[] buffer, int index, int count)
void Throw(string res, string[] args, Exception innerException)
static void StripSpaces(char[] value, int index, ref int len)
int GetIndexOfAttributeWithoutPrefix(string name)
void ThrowTagMismatch(NodeData startTag)
Task ParseEndElementAsync_CheckEndTag(int nameLen, NodeData startTagNode, LineInfo endTagLineInfo)
void PushInternalEntity(IDtdEntityInfo entity)
void ThrowWithoutLineInfo(string res, string[] args, Exception innerException)
void SendValidationEvent(XmlSeverityType severity, XmlSchemaException exception)
async Task ParseAttributeValueSlowAsync(int curPos, char quoteChar, NodeData attr)
void ThrowInvalidChar(char[] data, int length, int invCharPos)
void Throw(string res, string arg, int lineNo, int linePos)
void ParseCDataOrComment(XmlNodeType type)
XmlNamespaceManager _namespaceManager
async Task< bool > _ParseDocumentContentAsync_WhiteSpace(Task< bool > task)
async Task< bool > DtdParserProxy_PushExternalSubsetAsync(string systemId, string publicId)
void InitStreamInput(Uri baseUri, string baseUriStr, Stream stream, Encoding encoding)
async Task< bool > ParseDoctypeDeclAsync()
Task< bool > ParseDocumentContentAsync_WhiteSpace()
override async Task< int > ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
void Throw(int pos, string res, string[] args)
override string GetAttribute(string localName, string namespaceURI)
async Task< string > _GetValueAsync()
void OnXmlReservedAttribute(NodeData attr)
async Task<(int, int, int, bool)> ParseTextAsync_AsyncFunc(Task<(int, int, int, bool)> task)
async Task<(int, int, int, bool)> ParseTextAsync_Surrogate(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
readonly Task<(int, int, int, bool)> _parseText_dummyTask
async Task< bool > ZeroEndingStreamAsync(int pos)
XmlParserContext _fragmentParserContext
Task< bool > ReadAsync_SwitchToInteractiveXmlDecl_Helper(bool finish)
void InitTextReaderInput(string baseUriStr, Uri baseUri, TextReader input)
ValueTask<(int, int, int, bool)> ParseTextAsync(int outOrChars)
Task ParseElementAsync_SetElement(int colonPos, int pos)
Task ParseElementAsync_ContinueWithSetElement(Task<(int, int)> task)
override Task< int > ReadElementContentAsBase64Async(byte[] buffer, int index, int count)
async Task< bool > PushExternalEntityAsync(IDtdEntityInfo entity)
override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
readonly StringBuilder _stringBuilder
Task InitStreamInputAsync(Uri baseUri, Stream stream, Encoding encoding)
XmlTextReaderImpl(TextReader input, XmlReaderSettings settings, string baseUriStr, XmlParserContext context)
async Task PushExternalEntityOrSubsetAsync(string publicId, string systemId, Uri baseUri, string entityName)
void AddNamespace(string prefix, string uri, NodeData attr)
async Task<(int, bool)> ReadDataInNameAsync(int pos)
static void BlockCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
async Task< bool > OpenAndPushAsync(Uri uri)
XmlTextReaderImpl(string xmlFragment, XmlParserContext context, XmlReaderSettings settings)
async Task<(int, int, bool)> ParsePIValueAsync()
void InitStreamInput(Uri baseUri, string baseUriStr, Stream stream, byte[] bytes, int byteCount, Encoding encoding)
async Task<(int, int, int, bool)> ParseTextAsync_ParseEntity(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
string IXmlNamespaceResolver. LookupPrefix(string namespaceName)
ParseEndElementParseFunction _parseEndElement_NextFunc
override bool MoveToAttribute(string localName, string namespaceURI)
bool ParseText(out int startPos, out int endPos, ref int outOrChars)
async Task DtdParserProxy_ParsePIAsync(StringBuilder sb)
OnDefaultAttributeUseDelegate _onDefaultAttributeUse
XmlTextReaderImpl(string url, TextReader input, XmlNameTable nt)
int ParseNamedCharRefInline(int startPos, bool expand, StringBuilder internalSubsetBuilder)
void SkipUntil(char stopChar, bool recognizeLiterals)
async Task<(int, int, bool)> ParseCDataOrCommentTupleAsync(XmlNodeType type)
Task<(int, int, int, bool)> ParseTextAsync(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
async Task< string > ParseEntityNameAsync()
XmlTextReaderImpl(string url, TextReader input)
async Task ParseCDataOrCommentAsync(XmlNodeType type)
bool ParsePIValue(out int outStartPos, out int outEndPos)
void OnDefaultNamespaceDecl(NodeData attr)
void OnNamespaceDecl(NodeData attr)
void PushExternalEntityOrSubset(string publicId, string systemId, Uri baseUri, string entityName)
string LookupNamespace(NodeData node)
bool UriEqual(Uri uri1, string uri1Str, string uri2Str, XmlResolver resolver)
async Task< bool > ParsePIAsync(StringBuilder piInDtdStringBuilder)
XmlTextReaderImpl(string uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
void AddAttributeChunkToList(NodeData attr, NodeData chunk, ref NodeData lastChunk)
void ThrowUnexpectedToken(string expectedToken1)
async Task< bool > _ParseTextAsync(Task<(int, int, int, bool)> parseTask)
Task SwitchEncodingAsync(Encoding newEncoding)
static string StripSpaces(string value)
NodeData AddAttribute(int endNamePos, int colonPos)
void InitTextReaderInput(string baseUriStr, TextReader input)
Task ProcessDtdFromParserContextAsync(XmlParserContext context)
NodeData AllocNode(int nodeIndex, int nodeDepth)
Encoding CheckEncoding(string newEncodingName)
override bool MoveToAttribute(string name)
async Task< EntityType > HandleGeneralEntityReferenceAsync(string name, bool isInAttributeValue, bool pushFakeEntityIfNullResolver, int entityStartLinePos)
IDictionary< string, string > IXmlNamespaceResolver. GetNamespacesInScope(XmlNamespaceScope scope)
void InitStreamInput(Stream stream, Encoding encoding)
void ChangeCurrentNodeType(XmlNodeType newNodeType)
int ParseQName(bool isQName, int startOffset, out int colonPos)
override int ReadContentAsBase64(byte[] buffer, int index, int count)
static void AdjustLineInfo(char[] chars, int startPos, int endPos, bool isNormalized, ref LineInfo lineInfo)
async Task< bool > ParseDocumentContentAsync_ParseEntity()
void ReThrow(Exception e, int lineNo, int linePos)
async Task<(EntityType, int)> ParseNumericCharRefAsync(bool expand, StringBuilder internalSubsetBuilder)
int ReadBinHex(byte[] array, int offset, int len)
string LookupPrefix(string namespaceName)
void InitStreamInput(string baseUriStr, Stream stream, Encoding encoding)
XmlTextReaderImpl(XmlResolver resolver, XmlReaderSettings settings, XmlParserContext context)
int IncrementalRead(Array array, int index, int count)
async Task<(int, EntityType)> HandleEntityReferenceAsync(bool isInAttributeValue, EntityExpandType expandType)
void SendValidationEvent(XmlSeverityType severity, string code, string arg, int lineNo, int linePos)
void InvalidCharRecovery(ref int bytesCount, out int charsCount)
XmlTextReaderImpl(string xmlFragment, XmlNodeType fragType, XmlParserContext context)
void Throw(string res, string arg, Exception innerException)
async Task< bool > MoveToNextContentNodeAsync(bool moveIfOnContentNode)
void ParseAttributeValueSlow(int curPos, char quoteChar, NodeData attr)
int DtdParserProxy_ParseNumericCharRef(StringBuilder internalSubsetBuilder)
WhitespaceHandling _whitespaceHandling
async Task< bool > ParseCommentAsync()
XmlNodeType GetTextNodeType(int orChars)
bool DtdParserProxy_PushExternalSubset(string systemId, string publicId)
NodeData AddAttributeNoChecks(string name, int attrDepth)
Task ParseEndElementAsync_Finish(int nameLen, NodeData startTagNode, LineInfo endTagLineInfo)
EntityType HandleEntityReference(bool isInAttributeValue, EntityExpandType expandType, out int charRefEndPos)
override void MoveToAttribute(int i)
int EatWhitespaces(StringBuilder sb)
override XmlReaderSettings Settings
XmlTextReaderImpl(Stream xmlFragment, XmlNodeType fragType, XmlParserContext context)
XmlTextReaderImpl(string url, Stream input)
bool MoveToNextContentNode(bool moveIfOnContentNode)
bool ParseXmlDeclaration(bool isTextDecl)
void Throw(string res, int lineNo, int linePos)
void Throw(int pos, string res)
XmlTextReaderImpl(TextReader input, XmlNameTable nt)
int GetChars(int maxCharsCount)
bool ParseCDataOrComment(XmlNodeType type, out int outStartPos, out int outEndPos)
bool ParseText_PartialValue(int pos, int rcount, int rpos, int orChars, char c)
void ThrowUnexpectedToken(string expectedToken1, string expectedToken2)
override string GetAttribute(int i)
override async Task SkipAsync()
XmlTextReaderImpl(Stream stream, byte[] bytes, int byteCount, XmlReaderSettings settings, Uri baseUri, string baseUriStr, XmlParserContext context, bool closeInput)
Task InitTextReaderInputAsync(string baseUriStr, TextReader input)
bool HandleEntityEnd(bool checkEntityNesting)
async Task< int > ReadElementContentAsBase64Async_Helper(Task< bool > task, byte[] buffer, int index, int count)
async Task< int > ParseNamedCharRefAsync(bool expand, StringBuilder internalSubsetBuilder)
ParseTextFunction _parseText_NextFunction
bool ParsePI(StringBuilder piInDtdStringBuilder)
async Task< int > DtdParserProxy_ParseNumericCharRefAsync(StringBuilder internalSubsetBuilder)
async Task DtdParserProxy_ParseCommentAsync(StringBuilder sb)
Dictionary< IDtdEntityInfo, IDtdEntityInfo > _currentEntities
void SetDtdInfo(IDtdInfo newDtdInfo)
async Task< bool > ParseXmlDeclarationAsync(bool isTextDecl)
int ParseNumericCharRef(bool expand, StringBuilder internalSubsetBuilder, out EntityType entityType)
void DtdParserProxy_PushInternalDtd(string baseUri, string internalDtd)
IncrementalReadCharsDecoder _readCharsDecoder
async Task< bool > InitReadContentAsBinaryAsync()
void DtdParserProxy_ParsePI(StringBuilder sb)
void Throw(string res, string arg)
int ReadChars(char[] buffer, int index, int count)
XmlTextReaderImpl(string url, XmlNameTable nt)
void InitFragmentReader(XmlNodeType fragmentType, XmlParserContext parserContext, bool allowXmlDeclFragment)
void RegisterConsumedCharacters(long characters, bool inEntityReference)
async Task SkipUntilAsync(char stopChar, bool recognizeLiterals)
async Task _ParseElementAsync_ContinueWithSetElement(Task<(int, int)> task)
async Task ParseElementAsync_ReadData(int pos)
async Task< bool > ParseDocumentContentAsync_ReadData(bool needMoreChars)
void SetupReadContentAsBinaryState(ParsingFunction inReadBinaryFunction)
void SwitchEncoding(Encoding newEncoding)
async Task ThrowTagMismatchAsync(NodeData startTag)
override async Task< int > ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
override XmlNamespaceManager NamespaceManager
async Task< int > EatWhitespacesAsync(StringBuilder sb)
async Task< bool > _ReadAsync_SwitchToInteractiveXmlDecl(Task< bool > task)
static UTF8Encoding UTF8BomThrowing
override async Task< int > ReadValueChunkAsync(char[] buffer, int index, int count)
override Task< int > ReadContentAsBase64Async(byte[] buffer, int index, int count)
NodeData AddNode(int nodeIndex, int nodeDepth)
override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
void Throw(string res, string[] args)
void Throw(int pos, string res, string arg)
async Task<(int, int)> ParseQNameAsync(bool isQName, int startOffset)
void DtdParserProxy_OnPublicId(string publicId, LineInfo keywordLineInfo, LineInfo publicLiteralLineInfo)
void InitStringInput(string baseUriStr, Encoding originalEncoding, string str)
async Task< bool > ParseElementContent_ReadData()
void SetupEncoding(Encoding encoding)
void ShiftBuffer(int sourcePos, int destPos, int count)
static void AdjustLineInfo(string str, int startPos, int endPos, bool isNormalized, ref LineInfo lineInfo)
bool DtdParserProxy_PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId)
override Task< bool > ReadAsync()
int ParseNumericCharRefInline(int startPos, bool expand, StringBuilder internalSubsetBuilder, out int charCount, out EntityType entityType)
EntityType HandleGeneralEntityReference(string name, bool isInAttributeValue, bool pushFakeEntityIfNullResolver, int entityStartLinePos)
static void AdjustLineInfo(ReadOnlySpan< char > chars, bool isNormalized, ref LineInfo lineInfo)
static void BlockCopyChars(char[] src, int srcOffset, char[] dst, int dstOffset, int count)
override int ReadValueChunk(char[] buffer, int index, int count)
delegate void OnDefaultAttributeUseDelegate(IDtdDefaultAttributeInfo defaultAttribute, XmlTextReaderImpl coreReader)
XmlTextReaderImpl(string url, Stream input, XmlNameTable nt)
Task< bool > ParseDocumentContentAsync_CData()
void ThrowUnexpectedToken(int pos, string expectedToken)
bool AddDefaultAttributeNonDtd(SchemaAttDef attrDef)
int ReadBase64(byte[] array, int offset, int len)
int DtdParserProxy_ParseNamedCharRef(bool expand, StringBuilder internalSubsetBuilder)
async Task< bool > InitReadElementContentAsBinaryAsync()
IValidationEventHandling _validationEventHandling
bool ParseText_NoValue(int outOrChars, int pos)
void ThrowWithoutLineInfo(string res, string arg)
override string LookupNamespace(string prefix)
async Task< int > ReadContentAsBinaryAsync(byte[] buffer, int index, int count)
NodeData AddAttribute(string localName, string prefix, string nameWPrefix)
void RegisterEntity(IDtdEntityInfo entity)
async Task<(int, int, int, bool)> ParseTextAsync_ReadData(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)
async Task<(int, bool)> DtdParserProxy_PushEntityAsync(IDtdEntityInfo entity)
Task< bool > ReadAsync_SwitchToInteractiveXmlDecl()
async Task InitStreamInputAsync(Uri baseUri, string baseUriStr, Stream stream, byte[] bytes, int byteCount, Encoding encoding)
int ReadElementContentAsBinary(byte[] buffer, int index, int count)
int GetIndexOfAttributeWithPrefix(string name)
void ProcessDtdFromParserContext(XmlParserContext context)
async Task< int > ReadElementContentAsBinaryAsync(byte[] buffer, int index, int count)
int ParseCharRefInline(int startPos, out int charCount, out EntityType entityType)
bool PushExternalEntity(IDtdEntityInfo entity)
void InitIncrementalRead(IncrementalReadDecoder decoder)
bool DtdParserProxy_PushEntity(IDtdEntityInfo entity, out int entityId)
int ParseQName(out int colonPos)
void InitStreamInput(Uri baseUri, Stream stream, Encoding encoding)
void DtdParserProxy_ParseComment(StringBuilder sb)
int ReadContentAsBinary(byte[] buffer, int index, int count)
static UTF8Encoding s_utf8BomThrowing
override int ReadContentAsBinHex(byte[] buffer, int index, int count)
Task InitTextReaderInputAsync(string baseUriStr, Uri baseUri, TextReader input)
Task< int > DtdParserProxy_ParseNamedCharRefAsync(bool expand, StringBuilder internalSubsetBuilder)
IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
override Task< string > GetValueAsync()
async Task ParseEndElementAsync_Finish(Task task, int nameLen, NodeData startTagNode, LineInfo endTagLineInfo)
override string GetAttribute(string name)
async Task< bool > ParseRootLevelWhitespaceAsync()
IncrementalReadDecoder _incReadDecoder
XmlTextReaderImpl(Stream input, XmlNameTable nt)
void DtdParserProxy_OnSystemId(string systemId, LineInfo keywordLineInfo, LineInfo systemLiteralLineInfo)
int ParseNamedCharRef(bool expand, StringBuilder internalSubsetBuilder)
NodeData AddDefaultAttributeInternal(string localName, string ns, string prefix, string value, int lineNo, int linePos, int valueLineNo, int valueLinePos, bool isXmlAttribute)
XmlTextReaderImpl(string xmlFragment, XmlParserContext context)
void ThrowUnexpectedToken(int pos, string expectedToken1, string expectedToken2)
void SetupFromParserContext(XmlParserContext context, XmlReaderSettings settings)
bool AddDefaultAttributeDtd(IDtdDefaultAttributeInfo defAttrInfo, bool definedInDtd, NodeData[] nameSortedNodeData)
IncrementalReadState _incReadState
int CompareTo(object? obj)
IDtdEntityInfo LookupEntity(string name)
XmlQualifiedName Name
Definition IDtdInfo.cs:7
bool HasNonCDataAttributes
Definition IDtdInfo.cs:13
IDtdAttributeListInfo LookupAttributeList(string prefix, string localName)
string InternalDtdSubset
Definition IDtdInfo.cs:9
bool HasDefaultAttributes
Definition IDtdInfo.cs:11
bool PushExternalSubset(string systemId, string publicId)
void ParsePI(StringBuilder sb)
Task ParsePIAsync(StringBuilder sb)
Task< int > ParseNumericCharRefAsync(StringBuilder internalSubsetBuilder)
Task< int > ParseNamedCharRefAsync(bool expand, StringBuilder internalSubsetBuilder)
void OnSystemId(string systemId, LineInfo keywordLineInfo, LineInfo systemLiteralLineInfo)
bool PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId)
Task ParseCommentAsync(StringBuilder sb)
void OnPublicId(string publicId, LineInfo keywordLineInfo, LineInfo publicLiteralLineInfo)
void PushInternalDtd(string baseUri, string internalDtd)
Task<(int, bool)> PushEntityAsync(IDtdEntityInfo entity)
void Throw(Exception e)
Task< bool > PushExternalSubsetAsync(string systemId, string publicId)
int ParseNamedCharRef(bool expand, StringBuilder internalSubsetBuilder)
void ParseComment(StringBuilder sb)
bool PushEntity(IDtdEntityInfo entity, out int entityId)
int ParseNumericCharRef(StringBuilder internalSubsetBuilder)
void SendEvent(Exception exception, XmlSeverityType severity)
IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
string? LookupPrefix(string namespaceName)
string? LookupNamespace(string prefix)
void Set(int lineNo, int linePos)
Definition LineInfo.cs:15
ParseTextState(int outOrChars, char[] chars, int pos, int rcount, int rpos, int orChars, char c)