mscorlib(4.0.0.0) API with additions
XmlReader.cs
2 using System.Diagnostics;
4 using System.IO;
5 using System.Text;
7 using System.Xml.Schema;
8 
9 namespace System.Xml
10 {
12  [DebuggerDisplay("{debuggerDisplayProxy}")]
13  [DebuggerDisplay("{debuggerDisplayProxy}")]
14  [global::__DynamicallyInvokable]
15  public abstract class XmlReader : IDisposable
16  {
17  [DebuggerDisplay("{ToString()}")]
18  private struct XmlReaderDebuggerDisplayProxy
19  {
20  private XmlReader reader;
21 
22  internal XmlReaderDebuggerDisplayProxy(XmlReader reader)
23  {
24  this.reader = reader;
25  }
26 
27  public override string ToString()
28  {
29  XmlNodeType nodeType = reader.NodeType;
30  string text = nodeType.ToString();
31  switch (nodeType)
32  {
33  case XmlNodeType.Element:
34  case XmlNodeType.EntityReference:
35  case XmlNodeType.EndElement:
36  case XmlNodeType.EndEntity:
37  text = text + ", Name=\"" + reader.Name + "\"";
38  break;
39  case XmlNodeType.Attribute:
40  case XmlNodeType.ProcessingInstruction:
41  text = text + ", Name=\"" + reader.Name + "\", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(reader.Value) + "\"";
42  break;
43  case XmlNodeType.Text:
44  case XmlNodeType.CDATA:
45  case XmlNodeType.Comment:
46  case XmlNodeType.Whitespace:
47  case XmlNodeType.SignificantWhitespace:
48  case XmlNodeType.XmlDeclaration:
49  text = text + ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(reader.Value) + "\"";
50  break;
51  case XmlNodeType.DocumentType:
52  text = text + ", Name=\"" + reader.Name + "'";
53  text = text + ", SYSTEM=\"" + reader.GetAttribute("SYSTEM") + "\"";
54  text = text + ", PUBLIC=\"" + reader.GetAttribute("PUBLIC") + "\"";
55  text = text + ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(reader.Value) + "\"";
56  break;
57  }
58  return text;
59  }
60  }
61 
62  private static uint IsTextualNodeBitmap = 24600u;
63 
64  private static uint CanReadContentAsBitmap = 123324u;
65 
66  private static uint HasValueBitmap = 157084u;
67 
68  internal const int DefaultBufferSize = 4096;
69 
70  internal const int BiggerBufferSize = 8192;
71 
72  internal const int MaxStreamLengthForDefaultBufferSize = 65536;
73 
74  internal const int AsyncBufferSize = 65536;
75 
79  [global::__DynamicallyInvokable]
80  public virtual XmlReaderSettings Settings
81  {
82  [global::__DynamicallyInvokable]
83  get
84  {
85  return null;
86  }
87  }
88 
92  [global::__DynamicallyInvokable]
93  public abstract XmlNodeType NodeType
94  {
95  [global::__DynamicallyInvokable]
96  get;
97  }
98 
114  [global::__DynamicallyInvokable]
115  public virtual string Name
116  {
117  [global::__DynamicallyInvokable]
118  get
119  {
120  if (Prefix.Length == 0)
121  {
122  return LocalName;
123  }
124  return NameTable.Add(Prefix + ":" + LocalName);
125  }
126  }
127 
131  [global::__DynamicallyInvokable]
132  public abstract string LocalName
133  {
134  [global::__DynamicallyInvokable]
135  get;
136  }
137 
141  [global::__DynamicallyInvokable]
142  public abstract string NamespaceURI
143  {
144  [global::__DynamicallyInvokable]
145  get;
146  }
147 
151  [global::__DynamicallyInvokable]
152  public abstract string Prefix
153  {
154  [global::__DynamicallyInvokable]
155  get;
156  }
157 
162  [global::__DynamicallyInvokable]
163  public virtual bool HasValue
164  {
165  [global::__DynamicallyInvokable]
166  get
167  {
168  return HasValueInternal(NodeType);
169  }
170  }
171 
193  [global::__DynamicallyInvokable]
194  public abstract string Value
195  {
196  [global::__DynamicallyInvokable]
197  get;
198  }
199 
203  [global::__DynamicallyInvokable]
204  public abstract int Depth
205  {
206  [global::__DynamicallyInvokable]
207  get;
208  }
209 
213  [global::__DynamicallyInvokable]
214  public abstract string BaseURI
215  {
216  [global::__DynamicallyInvokable]
217  get;
218  }
219 
224  [global::__DynamicallyInvokable]
225  public abstract bool IsEmptyElement
226  {
227  [global::__DynamicallyInvokable]
228  get;
229  }
230 
235  [global::__DynamicallyInvokable]
236  public virtual bool IsDefault
237  {
238  [global::__DynamicallyInvokable]
239  get
240  {
241  return false;
242  }
243  }
244 
248  public virtual char QuoteChar => '"';
249 
253  [global::__DynamicallyInvokable]
254  public virtual XmlSpace XmlSpace
255  {
256  [global::__DynamicallyInvokable]
257  get
258  {
259  return XmlSpace.None;
260  }
261  }
262 
266  [global::__DynamicallyInvokable]
267  public virtual string XmlLang
268  {
269  [global::__DynamicallyInvokable]
270  get
271  {
272  return string.Empty;
273  }
274  }
275 
279  public virtual IXmlSchemaInfo SchemaInfo => this as IXmlSchemaInfo;
280 
284  [global::__DynamicallyInvokable]
285  public virtual Type ValueType
286  {
287  [global::__DynamicallyInvokable]
288  get
289  {
290  return typeof(string);
291  }
292  }
293 
297  [global::__DynamicallyInvokable]
298  public abstract int AttributeCount
299  {
300  [global::__DynamicallyInvokable]
301  get;
302  }
303 
308  [global::__DynamicallyInvokable]
309  public virtual string this[int i]
310  {
311  [global::__DynamicallyInvokable]
312  get
313  {
314  return GetAttribute(i);
315  }
316  }
317 
322  [global::__DynamicallyInvokable]
323  public virtual string this[string name]
324  {
325  [global::__DynamicallyInvokable]
326  get
327  {
328  return GetAttribute(name);
329  }
330  }
331 
337  [global::__DynamicallyInvokable]
338  public virtual string this[string name, string namespaceURI]
339  {
340  [global::__DynamicallyInvokable]
341  get
342  {
343  return GetAttribute(name, namespaceURI);
344  }
345  }
346 
351  [global::__DynamicallyInvokable]
352  public abstract bool EOF
353  {
354  [global::__DynamicallyInvokable]
355  get;
356  }
357 
361  [global::__DynamicallyInvokable]
362  public abstract ReadState ReadState
363  {
364  [global::__DynamicallyInvokable]
365  get;
366  }
367 
371  [global::__DynamicallyInvokable]
372  public abstract XmlNameTable NameTable
373  {
374  [global::__DynamicallyInvokable]
375  get;
376  }
377 
382  [global::__DynamicallyInvokable]
383  public virtual bool CanResolveEntity
384  {
385  [global::__DynamicallyInvokable]
386  get
387  {
388  return false;
389  }
390  }
391 
396  [global::__DynamicallyInvokable]
397  public virtual bool CanReadBinaryContent
398  {
399  [global::__DynamicallyInvokable]
400  get
401  {
402  return false;
403  }
404  }
405 
410  [global::__DynamicallyInvokable]
411  public virtual bool CanReadValueChunk
412  {
413  [global::__DynamicallyInvokable]
414  get
415  {
416  return false;
417  }
418  }
419 
424  [global::__DynamicallyInvokable]
425  public virtual bool HasAttributes
426  {
427  [global::__DynamicallyInvokable]
428  get
429  {
430  return AttributeCount > 0;
431  }
432  }
433 
434  internal virtual XmlNamespaceManager NamespaceManager => null;
435 
436  internal bool IsDefaultInternal
437  {
438  get
439  {
440  if (IsDefault)
441  {
442  return true;
443  }
444  IXmlSchemaInfo schemaInfo = SchemaInfo;
445  if (schemaInfo != null && schemaInfo.IsDefault)
446  {
447  return true;
448  }
449  return false;
450  }
451  }
452 
453  internal virtual IDtdInfo DtdInfo => null;
454 
455  private object debuggerDisplayProxy => new XmlReaderDebuggerDisplayProxy(this);
456 
462  [global::__DynamicallyInvokable]
463  public virtual object ReadContentAsObject()
464  {
465  if (!CanReadContentAs())
466  {
467  throw CreateReadContentAsException("ReadContentAsObject");
468  }
469  return InternalReadContentAsString();
470  }
471 
477  [global::__DynamicallyInvokable]
478  public virtual bool ReadContentAsBoolean()
479  {
480  if (!CanReadContentAs())
481  {
482  throw CreateReadContentAsException("ReadContentAsBoolean");
483  }
484  try
485  {
486  return XmlConvert.ToBoolean(InternalReadContentAsString());
487  }
488  catch (FormatException innerException)
489  {
490  throw new XmlException("Xml_ReadContentAsFormatException", "Boolean", innerException, this as IXmlLineInfo);
491  }
492  }
493 
500  {
501  if (!CanReadContentAs())
502  {
503  throw CreateReadContentAsException("ReadContentAsDateTime");
504  }
505  try
506  {
507  return XmlConvert.ToDateTime(InternalReadContentAsString(), XmlDateTimeSerializationMode.RoundtripKind);
508  }
509  catch (FormatException innerException)
510  {
511  throw new XmlException("Xml_ReadContentAsFormatException", "DateTime", innerException, this as IXmlLineInfo);
512  }
513  }
514 
518  [global::__DynamicallyInvokable]
520  {
521  if (!CanReadContentAs())
522  {
523  throw CreateReadContentAsException("ReadContentAsDateTimeOffset");
524  }
525  try
526  {
527  return XmlConvert.ToDateTimeOffset(InternalReadContentAsString());
528  }
529  catch (FormatException innerException)
530  {
531  throw new XmlException("Xml_ReadContentAsFormatException", "DateTimeOffset", innerException, this as IXmlLineInfo);
532  }
533  }
534 
540  [global::__DynamicallyInvokable]
541  public virtual double ReadContentAsDouble()
542  {
543  if (!CanReadContentAs())
544  {
545  throw CreateReadContentAsException("ReadContentAsDouble");
546  }
547  try
548  {
549  return XmlConvert.ToDouble(InternalReadContentAsString());
550  }
551  catch (FormatException innerException)
552  {
553  throw new XmlException("Xml_ReadContentAsFormatException", "Double", innerException, this as IXmlLineInfo);
554  }
555  }
556 
562  [global::__DynamicallyInvokable]
563  public virtual float ReadContentAsFloat()
564  {
565  if (!CanReadContentAs())
566  {
567  throw CreateReadContentAsException("ReadContentAsFloat");
568  }
569  try
570  {
571  return XmlConvert.ToSingle(InternalReadContentAsString());
572  }
573  catch (FormatException innerException)
574  {
575  throw new XmlException("Xml_ReadContentAsFormatException", "Float", innerException, this as IXmlLineInfo);
576  }
577  }
578 
584  [global::__DynamicallyInvokable]
585  public virtual decimal ReadContentAsDecimal()
586  {
587  if (!CanReadContentAs())
588  {
589  throw CreateReadContentAsException("ReadContentAsDecimal");
590  }
591  try
592  {
593  return XmlConvert.ToDecimal(InternalReadContentAsString());
594  }
595  catch (FormatException innerException)
596  {
597  throw new XmlException("Xml_ReadContentAsFormatException", "Decimal", innerException, this as IXmlLineInfo);
598  }
599  }
600 
606  [global::__DynamicallyInvokable]
607  public virtual int ReadContentAsInt()
608  {
609  if (!CanReadContentAs())
610  {
611  throw CreateReadContentAsException("ReadContentAsInt");
612  }
613  try
614  {
615  return XmlConvert.ToInt32(InternalReadContentAsString());
616  }
617  catch (FormatException innerException)
618  {
619  throw new XmlException("Xml_ReadContentAsFormatException", "Int", innerException, this as IXmlLineInfo);
620  }
621  }
622 
628  [global::__DynamicallyInvokable]
629  public virtual long ReadContentAsLong()
630  {
631  if (!CanReadContentAs())
632  {
633  throw CreateReadContentAsException("ReadContentAsLong");
634  }
635  try
636  {
637  return XmlConvert.ToInt64(InternalReadContentAsString());
638  }
639  catch (FormatException innerException)
640  {
641  throw new XmlException("Xml_ReadContentAsFormatException", "Long", innerException, this as IXmlLineInfo);
642  }
643  }
644 
650  [global::__DynamicallyInvokable]
651  public virtual string ReadContentAsString()
652  {
653  if (!CanReadContentAs())
654  {
655  throw CreateReadContentAsException("ReadContentAsString");
656  }
657  return InternalReadContentAsString();
658  }
659 
671  [global::__DynamicallyInvokable]
672  public virtual object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver)
673  {
674  if (!CanReadContentAs())
675  {
676  throw CreateReadContentAsException("ReadContentAs");
677  }
678  string text = InternalReadContentAsString();
679  if (returnType == typeof(string))
680  {
681  return text;
682  }
683  try
684  {
685  return XmlUntypedConverter.Untyped.ChangeType(text, returnType, (namespaceResolver == null) ? (this as IXmlNamespaceResolver) : namespaceResolver);
686  }
687  catch (FormatException innerException)
688  {
689  throw new XmlException("Xml_ReadContentAsFormatException", returnType.ToString(), innerException, this as IXmlLineInfo);
690  }
691  catch (InvalidCastException innerException2)
692  {
693  throw new XmlException("Xml_ReadContentAsFormatException", returnType.ToString(), innerException2, this as IXmlLineInfo);
694  }
695  }
696 
703  [global::__DynamicallyInvokable]
704  public virtual object ReadElementContentAsObject()
705  {
706  if (SetupReadElementContentAsXxx("ReadElementContentAsObject"))
707  {
708  object result = ReadContentAsObject();
709  FinishReadElementContentAsXxx();
710  return result;
711  }
712  return string.Empty;
713  }
714 
724  [global::__DynamicallyInvokable]
725  public virtual object ReadElementContentAsObject(string localName, string namespaceURI)
726  {
727  CheckElement(localName, namespaceURI);
729  }
730 
737  [global::__DynamicallyInvokable]
738  public virtual bool ReadElementContentAsBoolean()
739  {
740  if (SetupReadElementContentAsXxx("ReadElementContentAsBoolean"))
741  {
742  bool result = ReadContentAsBoolean();
743  FinishReadElementContentAsXxx();
744  return result;
745  }
746  return XmlConvert.ToBoolean(string.Empty);
747  }
748 
758  [global::__DynamicallyInvokable]
759  public virtual bool ReadElementContentAsBoolean(string localName, string namespaceURI)
760  {
761  CheckElement(localName, namespaceURI);
763  }
764 
772  {
773  if (SetupReadElementContentAsXxx("ReadElementContentAsDateTime"))
774  {
775  DateTime result = ReadContentAsDateTime();
776  FinishReadElementContentAsXxx();
777  return result;
778  }
779  return XmlConvert.ToDateTime(string.Empty, XmlDateTimeSerializationMode.RoundtripKind);
780  }
781 
791  public virtual DateTime ReadElementContentAsDateTime(string localName, string namespaceURI)
792  {
793  CheckElement(localName, namespaceURI);
795  }
796 
803  [global::__DynamicallyInvokable]
804  public virtual double ReadElementContentAsDouble()
805  {
806  if (SetupReadElementContentAsXxx("ReadElementContentAsDouble"))
807  {
808  double result = ReadContentAsDouble();
809  FinishReadElementContentAsXxx();
810  return result;
811  }
812  return XmlConvert.ToDouble(string.Empty);
813  }
814 
824  [global::__DynamicallyInvokable]
825  public virtual double ReadElementContentAsDouble(string localName, string namespaceURI)
826  {
827  CheckElement(localName, namespaceURI);
829  }
830 
837  [global::__DynamicallyInvokable]
838  public virtual float ReadElementContentAsFloat()
839  {
840  if (SetupReadElementContentAsXxx("ReadElementContentAsFloat"))
841  {
842  float result = ReadContentAsFloat();
843  FinishReadElementContentAsXxx();
844  return result;
845  }
846  return XmlConvert.ToSingle(string.Empty);
847  }
848 
858  [global::__DynamicallyInvokable]
859  public virtual float ReadElementContentAsFloat(string localName, string namespaceURI)
860  {
861  CheckElement(localName, namespaceURI);
862  return ReadElementContentAsFloat();
863  }
864 
871  [global::__DynamicallyInvokable]
872  public virtual decimal ReadElementContentAsDecimal()
873  {
874  if (SetupReadElementContentAsXxx("ReadElementContentAsDecimal"))
875  {
876  decimal result = ReadContentAsDecimal();
877  FinishReadElementContentAsXxx();
878  return result;
879  }
880  return XmlConvert.ToDecimal(string.Empty);
881  }
882 
892  [global::__DynamicallyInvokable]
893  public virtual decimal ReadElementContentAsDecimal(string localName, string namespaceURI)
894  {
895  CheckElement(localName, namespaceURI);
897  }
898 
905  [global::__DynamicallyInvokable]
906  public virtual int ReadElementContentAsInt()
907  {
908  if (SetupReadElementContentAsXxx("ReadElementContentAsInt"))
909  {
910  int result = ReadContentAsInt();
911  FinishReadElementContentAsXxx();
912  return result;
913  }
914  return XmlConvert.ToInt32(string.Empty);
915  }
916 
926  [global::__DynamicallyInvokable]
927  public virtual int ReadElementContentAsInt(string localName, string namespaceURI)
928  {
929  CheckElement(localName, namespaceURI);
930  return ReadElementContentAsInt();
931  }
932 
939  [global::__DynamicallyInvokable]
940  public virtual long ReadElementContentAsLong()
941  {
942  if (SetupReadElementContentAsXxx("ReadElementContentAsLong"))
943  {
944  long result = ReadContentAsLong();
945  FinishReadElementContentAsXxx();
946  return result;
947  }
948  return XmlConvert.ToInt64(string.Empty);
949  }
950 
960  [global::__DynamicallyInvokable]
961  public virtual long ReadElementContentAsLong(string localName, string namespaceURI)
962  {
963  CheckElement(localName, namespaceURI);
964  return ReadElementContentAsLong();
965  }
966 
973  [global::__DynamicallyInvokable]
974  public virtual string ReadElementContentAsString()
975  {
976  if (SetupReadElementContentAsXxx("ReadElementContentAsString"))
977  {
978  string result = ReadContentAsString();
979  FinishReadElementContentAsXxx();
980  return result;
981  }
982  return string.Empty;
983  }
984 
994  [global::__DynamicallyInvokable]
995  public virtual string ReadElementContentAsString(string localName, string namespaceURI)
996  {
997  CheckElement(localName, namespaceURI);
999  }
1000 
1011  [global::__DynamicallyInvokable]
1012  public virtual object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver)
1013  {
1014  if (SetupReadElementContentAsXxx("ReadElementContentAs"))
1015  {
1016  object result = ReadContentAs(returnType, namespaceResolver);
1017  FinishReadElementContentAsXxx();
1018  return result;
1019  }
1020  if (!(returnType == typeof(string)))
1021  {
1022  return XmlUntypedConverter.Untyped.ChangeType(string.Empty, returnType, namespaceResolver);
1023  }
1024  return string.Empty;
1025  }
1026 
1040  [global::__DynamicallyInvokable]
1041  public virtual object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver, string localName, string namespaceURI)
1042  {
1043  CheckElement(localName, namespaceURI);
1044  return ReadElementContentAs(returnType, namespaceResolver);
1045  }
1046 
1053  [global::__DynamicallyInvokable]
1054  public abstract string GetAttribute(string name);
1055 
1063  [global::__DynamicallyInvokable]
1064  public abstract string GetAttribute(string name, string namespaceURI);
1065 
1072  [global::__DynamicallyInvokable]
1073  public abstract string GetAttribute(int i);
1074 
1081  [global::__DynamicallyInvokable]
1082  public abstract bool MoveToAttribute(string name);
1083 
1091  [global::__DynamicallyInvokable]
1092  public abstract bool MoveToAttribute(string name, string ns);
1093 
1098  [global::__DynamicallyInvokable]
1099  public virtual void MoveToAttribute(int i)
1100  {
1101  if (i < 0 || i >= AttributeCount)
1102  {
1103  throw new ArgumentOutOfRangeException("i");
1104  }
1105  MoveToElement();
1107  for (int j = 0; j < i; j++)
1108  {
1110  }
1111  }
1112 
1117  [global::__DynamicallyInvokable]
1118  public abstract bool MoveToFirstAttribute();
1119 
1124  [global::__DynamicallyInvokable]
1125  public abstract bool MoveToNextAttribute();
1126 
1131  [global::__DynamicallyInvokable]
1132  public abstract bool MoveToElement();
1133 
1139  [global::__DynamicallyInvokable]
1140  public abstract bool ReadAttributeValue();
1141 
1147  [global::__DynamicallyInvokable]
1148  public abstract bool Read();
1149 
1152  public virtual void Close()
1153  {
1154  }
1155 
1158  [global::__DynamicallyInvokable]
1159  public virtual void Skip()
1160  {
1161  if (ReadState == ReadState.Interactive)
1162  {
1163  SkipSubtree();
1164  }
1165  }
1166 
1171  [global::__DynamicallyInvokable]
1172  public abstract string LookupNamespace(string prefix);
1173 
1177  [global::__DynamicallyInvokable]
1178  public abstract void ResolveEntity();
1179 
1191  [global::__DynamicallyInvokable]
1192  public virtual int ReadContentAsBase64(byte[] buffer, int index, int count)
1193  {
1194  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadContentAsBase64"));
1195  }
1196 
1209  [global::__DynamicallyInvokable]
1210  public virtual int ReadElementContentAsBase64(byte[] buffer, int index, int count)
1211  {
1212  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadElementContentAsBase64"));
1213  }
1214 
1226  [global::__DynamicallyInvokable]
1227  public virtual int ReadContentAsBinHex(byte[] buffer, int index, int count)
1228  {
1229  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadContentAsBinHex"));
1230  }
1231 
1244  [global::__DynamicallyInvokable]
1245  public virtual int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
1246  {
1247  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadElementContentAsBinHex"));
1248  }
1249 
1261  [global::__DynamicallyInvokable]
1262  public virtual int ReadValueChunk(char[] buffer, int index, int count)
1263  {
1264  throw new NotSupportedException(Res.GetString("Xml_ReadValueChunkNotSupported"));
1265  }
1266 
1271  [EditorBrowsable(EditorBrowsableState.Never)]
1272  public virtual string ReadString()
1273  {
1274  if (ReadState != ReadState.Interactive)
1275  {
1276  return string.Empty;
1277  }
1278  MoveToElement();
1279  if (NodeType == XmlNodeType.Element)
1280  {
1281  if (IsEmptyElement)
1282  {
1283  return string.Empty;
1284  }
1285  if (!Read())
1286  {
1287  throw new InvalidOperationException(Res.GetString("Xml_InvalidOperation"));
1288  }
1289  if (NodeType == XmlNodeType.EndElement)
1290  {
1291  return string.Empty;
1292  }
1293  }
1294  string text = string.Empty;
1295  while (IsTextualNode(NodeType))
1296  {
1297  text += Value;
1298  if (!Read())
1299  {
1300  break;
1301  }
1302  }
1303  return text;
1304  }
1305 
1310  [global::__DynamicallyInvokable]
1311  public virtual XmlNodeType MoveToContent()
1312  {
1313  do
1314  {
1315  switch (NodeType)
1316  {
1317  case XmlNodeType.Attribute:
1318  MoveToElement();
1319  break;
1320  case XmlNodeType.Element:
1321  case XmlNodeType.Text:
1322  case XmlNodeType.CDATA:
1323  case XmlNodeType.EntityReference:
1324  case XmlNodeType.EndElement:
1325  case XmlNodeType.EndEntity:
1326  break;
1327  default:
1328  continue;
1329  }
1330  return NodeType;
1331  }
1332  while (Read());
1333  return NodeType;
1334  }
1335 
1339  [global::__DynamicallyInvokable]
1340  public virtual void ReadStartElement()
1341  {
1342  if (MoveToContent() != XmlNodeType.Element)
1343  {
1344  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1345  }
1346  Read();
1347  }
1348 
1353  [global::__DynamicallyInvokable]
1354  public virtual void ReadStartElement(string name)
1355  {
1356  if (MoveToContent() != XmlNodeType.Element)
1357  {
1358  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1359  }
1360  if (Name == name)
1361  {
1362  Read();
1363  return;
1364  }
1365  throw new XmlException("Xml_ElementNotFound", name, this as IXmlLineInfo);
1366  }
1367 
1373  [global::__DynamicallyInvokable]
1374  public virtual void ReadStartElement(string localname, string ns)
1375  {
1376  if (MoveToContent() != XmlNodeType.Element)
1377  {
1378  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1379  }
1380  if (LocalName == localname && NamespaceURI == ns)
1381  {
1382  Read();
1383  return;
1384  }
1385  throw new XmlException("Xml_ElementNotFoundNs", new string[2]
1386  {
1387  localname,
1388  ns
1389  }, this as IXmlLineInfo);
1390  }
1391 
1396  [EditorBrowsable(EditorBrowsableState.Never)]
1397  public virtual string ReadElementString()
1398  {
1399  string result = string.Empty;
1400  if (MoveToContent() != XmlNodeType.Element)
1401  {
1402  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1403  }
1404  if (!IsEmptyElement)
1405  {
1406  Read();
1407  result = ReadString();
1408  if (NodeType != XmlNodeType.EndElement)
1409  {
1410  throw new XmlException("Xml_UnexpectedNodeInSimpleContent", new string[2]
1411  {
1412  NodeType.ToString(),
1413  "ReadElementString"
1414  }, this as IXmlLineInfo);
1415  }
1416  Read();
1417  }
1418  else
1419  {
1420  Read();
1421  }
1422  return result;
1423  }
1424 
1430  [EditorBrowsable(EditorBrowsableState.Never)]
1431  public virtual string ReadElementString(string name)
1432  {
1433  string result = string.Empty;
1434  if (MoveToContent() != XmlNodeType.Element)
1435  {
1436  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1437  }
1438  if (Name != name)
1439  {
1440  throw new XmlException("Xml_ElementNotFound", name, this as IXmlLineInfo);
1441  }
1442  if (!IsEmptyElement)
1443  {
1444  result = ReadString();
1445  if (NodeType != XmlNodeType.EndElement)
1446  {
1447  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1448  }
1449  Read();
1450  }
1451  else
1452  {
1453  Read();
1454  }
1455  return result;
1456  }
1457 
1464  [EditorBrowsable(EditorBrowsableState.Never)]
1465  public virtual string ReadElementString(string localname, string ns)
1466  {
1467  string result = string.Empty;
1468  if (MoveToContent() != XmlNodeType.Element)
1469  {
1470  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1471  }
1472  if (LocalName != localname || NamespaceURI != ns)
1473  {
1474  throw new XmlException("Xml_ElementNotFoundNs", new string[2]
1475  {
1476  localname,
1477  ns
1478  }, this as IXmlLineInfo);
1479  }
1480  if (!IsEmptyElement)
1481  {
1482  result = ReadString();
1483  if (NodeType != XmlNodeType.EndElement)
1484  {
1485  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1486  }
1487  Read();
1488  }
1489  else
1490  {
1491  Read();
1492  }
1493  return result;
1494  }
1495 
1499  [global::__DynamicallyInvokable]
1500  public virtual void ReadEndElement()
1501  {
1502  if (MoveToContent() != XmlNodeType.EndElement)
1503  {
1504  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
1505  }
1506  Read();
1507  }
1508 
1514  [global::__DynamicallyInvokable]
1515  public virtual bool IsStartElement()
1516  {
1517  return MoveToContent() == XmlNodeType.Element;
1518  }
1519 
1526  [global::__DynamicallyInvokable]
1527  public virtual bool IsStartElement(string name)
1528  {
1529  if (MoveToContent() == XmlNodeType.Element)
1530  {
1531  return Name == name;
1532  }
1533  return false;
1534  }
1535 
1543  [global::__DynamicallyInvokable]
1544  public virtual bool IsStartElement(string localname, string ns)
1545  {
1546  if (MoveToContent() == XmlNodeType.Element)
1547  {
1548  if (LocalName == localname)
1549  {
1550  return NamespaceURI == ns;
1551  }
1552  return false;
1553  }
1554  return false;
1555  }
1556 
1563  [global::__DynamicallyInvokable]
1564  public virtual bool ReadToFollowing(string name)
1565  {
1566  if (name == null || name.Length == 0)
1567  {
1568  throw XmlConvert.CreateInvalidNameArgumentException(name, "name");
1569  }
1570  name = NameTable.Add(name);
1571  while (Read())
1572  {
1573  if (NodeType == XmlNodeType.Element && Ref.Equal(name, Name))
1574  {
1575  return true;
1576  }
1577  }
1578  return false;
1579  }
1580 
1588  [global::__DynamicallyInvokable]
1589  public virtual bool ReadToFollowing(string localName, string namespaceURI)
1590  {
1591  if (localName == null || localName.Length == 0)
1592  {
1593  throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName");
1594  }
1595  if (namespaceURI == null)
1596  {
1597  throw new ArgumentNullException("namespaceURI");
1598  }
1599  localName = NameTable.Add(localName);
1600  namespaceURI = NameTable.Add(namespaceURI);
1601  while (Read())
1602  {
1603  if (NodeType == XmlNodeType.Element && Ref.Equal(localName, LocalName) && Ref.Equal(namespaceURI, NamespaceURI))
1604  {
1605  return true;
1606  }
1607  }
1608  return false;
1609  }
1610 
1617  [global::__DynamicallyInvokable]
1618  public virtual bool ReadToDescendant(string name)
1619  {
1620  if (name == null || name.Length == 0)
1621  {
1622  throw XmlConvert.CreateInvalidNameArgumentException(name, "name");
1623  }
1624  int num = Depth;
1625  if (NodeType != XmlNodeType.Element)
1626  {
1627  if (ReadState != 0)
1628  {
1629  return false;
1630  }
1631  num--;
1632  }
1633  else if (IsEmptyElement)
1634  {
1635  return false;
1636  }
1637  name = NameTable.Add(name);
1638  while (Read() && Depth > num)
1639  {
1640  if (NodeType == XmlNodeType.Element && Ref.Equal(name, Name))
1641  {
1642  return true;
1643  }
1644  }
1645  return false;
1646  }
1647 
1655  [global::__DynamicallyInvokable]
1656  public virtual bool ReadToDescendant(string localName, string namespaceURI)
1657  {
1658  if (localName == null || localName.Length == 0)
1659  {
1660  throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName");
1661  }
1662  if (namespaceURI == null)
1663  {
1664  throw new ArgumentNullException("namespaceURI");
1665  }
1666  int num = Depth;
1667  if (NodeType != XmlNodeType.Element)
1668  {
1669  if (ReadState != 0)
1670  {
1671  return false;
1672  }
1673  num--;
1674  }
1675  else if (IsEmptyElement)
1676  {
1677  return false;
1678  }
1679  localName = NameTable.Add(localName);
1680  namespaceURI = NameTable.Add(namespaceURI);
1681  while (Read() && Depth > num)
1682  {
1683  if (NodeType == XmlNodeType.Element && Ref.Equal(localName, LocalName) && Ref.Equal(namespaceURI, NamespaceURI))
1684  {
1685  return true;
1686  }
1687  }
1688  return false;
1689  }
1690 
1697  [global::__DynamicallyInvokable]
1698  public virtual bool ReadToNextSibling(string name)
1699  {
1700  if (name == null || name.Length == 0)
1701  {
1702  throw XmlConvert.CreateInvalidNameArgumentException(name, "name");
1703  }
1704  name = NameTable.Add(name);
1705  while (SkipSubtree())
1706  {
1707  XmlNodeType nodeType = NodeType;
1708  if (nodeType == XmlNodeType.Element && Ref.Equal(name, Name))
1709  {
1710  return true;
1711  }
1712  if (nodeType == XmlNodeType.EndElement || EOF)
1713  {
1714  break;
1715  }
1716  }
1717  return false;
1718  }
1719 
1727  [global::__DynamicallyInvokable]
1728  public virtual bool ReadToNextSibling(string localName, string namespaceURI)
1729  {
1730  if (localName == null || localName.Length == 0)
1731  {
1732  throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName");
1733  }
1734  if (namespaceURI == null)
1735  {
1736  throw new ArgumentNullException("namespaceURI");
1737  }
1738  localName = NameTable.Add(localName);
1739  namespaceURI = NameTable.Add(namespaceURI);
1740  while (SkipSubtree())
1741  {
1742  XmlNodeType nodeType = NodeType;
1743  if (nodeType == XmlNodeType.Element && Ref.Equal(localName, LocalName) && Ref.Equal(namespaceURI, NamespaceURI))
1744  {
1745  return true;
1746  }
1747  if (nodeType == XmlNodeType.EndElement || EOF)
1748  {
1749  break;
1750  }
1751  }
1752  return false;
1753  }
1754 
1760  [global::__DynamicallyInvokable]
1761  public static bool IsName(string str)
1762  {
1763  if (str == null)
1764  {
1765  throw new NullReferenceException();
1766  }
1767  return ValidateNames.IsNameNoNamespaces(str);
1768  }
1769 
1775  [global::__DynamicallyInvokable]
1776  public static bool IsNameToken(string str)
1777  {
1778  if (str == null)
1779  {
1780  throw new NullReferenceException();
1781  }
1782  return ValidateNames.IsNmtokenNoNamespaces(str);
1783  }
1784 
1789  [global::__DynamicallyInvokable]
1790  public virtual string ReadInnerXml()
1791  {
1792  if (ReadState != ReadState.Interactive)
1793  {
1794  return string.Empty;
1795  }
1796  if (NodeType != XmlNodeType.Attribute && NodeType != XmlNodeType.Element)
1797  {
1798  Read();
1799  return string.Empty;
1800  }
1802  XmlWriter xmlWriter = CreateWriterForInnerOuterXml(stringWriter);
1803  try
1804  {
1805  if (NodeType == XmlNodeType.Attribute)
1806  {
1807  ((XmlTextWriter)xmlWriter).QuoteChar = QuoteChar;
1808  WriteAttributeValue(xmlWriter);
1809  }
1810  if (NodeType == XmlNodeType.Element)
1811  {
1812  WriteNode(xmlWriter, defattr: false);
1813  }
1814  }
1815  finally
1816  {
1817  xmlWriter.Close();
1818  }
1819  return stringWriter.ToString();
1820  }
1821 
1822  private void WriteNode(XmlWriter xtw, bool defattr)
1823  {
1824  int num = (NodeType == XmlNodeType.None) ? (-1) : Depth;
1825  while (Read() && num < Depth)
1826  {
1827  switch (NodeType)
1828  {
1829  case XmlNodeType.Element:
1831  ((XmlTextWriter)xtw).QuoteChar = QuoteChar;
1832  xtw.WriteAttributes(this, defattr);
1833  if (IsEmptyElement)
1834  {
1835  xtw.WriteEndElement();
1836  }
1837  break;
1838  case XmlNodeType.Text:
1839  xtw.WriteString(Value);
1840  break;
1841  case XmlNodeType.Whitespace:
1842  case XmlNodeType.SignificantWhitespace:
1843  xtw.WriteWhitespace(Value);
1844  break;
1845  case XmlNodeType.CDATA:
1846  xtw.WriteCData(Value);
1847  break;
1848  case XmlNodeType.EntityReference:
1849  xtw.WriteEntityRef(Name);
1850  break;
1851  case XmlNodeType.ProcessingInstruction:
1852  case XmlNodeType.XmlDeclaration:
1854  break;
1855  case XmlNodeType.DocumentType:
1856  xtw.WriteDocType(Name, GetAttribute("PUBLIC"), GetAttribute("SYSTEM"), Value);
1857  break;
1858  case XmlNodeType.Comment:
1859  xtw.WriteComment(Value);
1860  break;
1861  case XmlNodeType.EndElement:
1862  xtw.WriteFullEndElement();
1863  break;
1864  }
1865  }
1866  if (num == Depth && NodeType == XmlNodeType.EndElement)
1867  {
1868  Read();
1869  }
1870  }
1871 
1872  private void WriteAttributeValue(XmlWriter xtw)
1873  {
1874  string name = Name;
1875  while (ReadAttributeValue())
1876  {
1877  if (NodeType == XmlNodeType.EntityReference)
1878  {
1879  xtw.WriteEntityRef(Name);
1880  }
1881  else
1882  {
1883  xtw.WriteString(Value);
1884  }
1885  }
1886  MoveToAttribute(name);
1887  }
1888 
1893  [global::__DynamicallyInvokable]
1894  public virtual string ReadOuterXml()
1895  {
1896  if (ReadState != ReadState.Interactive)
1897  {
1898  return string.Empty;
1899  }
1900  if (NodeType != XmlNodeType.Attribute && NodeType != XmlNodeType.Element)
1901  {
1902  Read();
1903  return string.Empty;
1904  }
1906  XmlWriter xmlWriter = CreateWriterForInnerOuterXml(stringWriter);
1907  try
1908  {
1909  if (NodeType == XmlNodeType.Attribute)
1910  {
1912  WriteAttributeValue(xmlWriter);
1913  xmlWriter.WriteEndAttribute();
1914  }
1915  else
1916  {
1917  xmlWriter.WriteNode(this, defattr: false);
1918  }
1919  }
1920  finally
1921  {
1922  xmlWriter.Close();
1923  }
1924  return stringWriter.ToString();
1925  }
1926 
1927  private XmlWriter CreateWriterForInnerOuterXml(StringWriter sw)
1928  {
1929  XmlTextWriter xmlTextWriter = new XmlTextWriter(sw);
1930  SetNamespacesFlag(xmlTextWriter);
1931  return xmlTextWriter;
1932  }
1933 
1934  private void SetNamespacesFlag(XmlTextWriter xtw)
1935  {
1936  XmlTextReader xmlTextReader = this as XmlTextReader;
1937  if (xmlTextReader != null)
1938  {
1939  xtw.Namespaces = xmlTextReader.Namespaces;
1940  return;
1941  }
1942  XmlValidatingReader xmlValidatingReader = this as XmlValidatingReader;
1943  if (xmlValidatingReader != null)
1944  {
1945  xtw.Namespaces = xmlValidatingReader.Namespaces;
1946  }
1947  }
1948 
1953  [global::__DynamicallyInvokable]
1954  public virtual XmlReader ReadSubtree()
1955  {
1956  if (NodeType != XmlNodeType.Element)
1957  {
1958  throw new InvalidOperationException(Res.GetString("Xml_ReadSubtreeNotOnElement"));
1959  }
1960  return new XmlSubtreeReader(this);
1961  }
1962 
1965  [global::__DynamicallyInvokable]
1966  public void Dispose()
1967  {
1968  Dispose(disposing: true);
1969  }
1970 
1975  [global::__DynamicallyInvokable]
1976  protected virtual void Dispose(bool disposing)
1977  {
1978  if (disposing && ReadState != ReadState.Closed)
1979  {
1980  Close();
1981  }
1982  }
1983 
1984  internal static bool IsTextualNode(XmlNodeType nodeType)
1985  {
1986  return (IsTextualNodeBitmap & (1 << (int)nodeType)) != 0;
1987  }
1988 
1989  internal static bool CanReadContentAs(XmlNodeType nodeType)
1990  {
1991  return (CanReadContentAsBitmap & (1 << (int)nodeType)) != 0;
1992  }
1993 
1994  internal static bool HasValueInternal(XmlNodeType nodeType)
1995  {
1996  return (HasValueBitmap & (1 << (int)nodeType)) != 0;
1997  }
1998 
1999  private bool SkipSubtree()
2000  {
2001  MoveToElement();
2002  if (NodeType == XmlNodeType.Element && !IsEmptyElement)
2003  {
2004  int depth = Depth;
2005  while (Read() && depth < Depth)
2006  {
2007  }
2008  if (NodeType == XmlNodeType.EndElement)
2009  {
2010  return Read();
2011  }
2012  return false;
2013  }
2014  return Read();
2015  }
2016 
2017  internal void CheckElement(string localName, string namespaceURI)
2018  {
2019  if (localName == null || localName.Length == 0)
2020  {
2021  throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName");
2022  }
2023  if (namespaceURI == null)
2024  {
2025  throw new ArgumentNullException("namespaceURI");
2026  }
2027  if (NodeType != XmlNodeType.Element)
2028  {
2029  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString(), this as IXmlLineInfo);
2030  }
2031  if (LocalName != localName || NamespaceURI != namespaceURI)
2032  {
2033  throw new XmlException("Xml_ElementNotFoundNs", new string[2]
2034  {
2035  localName,
2036  namespaceURI
2037  }, this as IXmlLineInfo);
2038  }
2039  }
2040 
2041  internal Exception CreateReadContentAsException(string methodName)
2042  {
2043  return CreateReadContentAsException(methodName, NodeType, this as IXmlLineInfo);
2044  }
2045 
2046  internal Exception CreateReadElementContentAsException(string methodName)
2047  {
2048  return CreateReadElementContentAsException(methodName, NodeType, this as IXmlLineInfo);
2049  }
2050 
2051  internal bool CanReadContentAs()
2052  {
2053  return CanReadContentAs(NodeType);
2054  }
2055 
2056  internal static Exception CreateReadContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo)
2057  {
2058  return new InvalidOperationException(AddLineInfo(Res.GetString("Xml_InvalidReadContentAs", methodName, nodeType.ToString()), lineInfo));
2059  }
2060 
2061  internal static Exception CreateReadElementContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo)
2062  {
2063  return new InvalidOperationException(AddLineInfo(Res.GetString("Xml_InvalidReadElementContentAs", methodName, nodeType.ToString()), lineInfo));
2064  }
2065 
2066  private static string AddLineInfo(string message, IXmlLineInfo lineInfo)
2067  {
2068  if (lineInfo != null)
2069  {
2070  message = message + " " + Res.GetString("Xml_ErrorPosition", lineInfo.LineNumber.ToString(CultureInfo.InvariantCulture), lineInfo.LinePosition.ToString(CultureInfo.InvariantCulture));
2071  }
2072  return message;
2073  }
2074 
2075  internal string InternalReadContentAsString()
2076  {
2077  string text = string.Empty;
2078  StringBuilder stringBuilder = null;
2079  bool num;
2080  do
2081  {
2082  switch (NodeType)
2083  {
2084  case XmlNodeType.Attribute:
2085  return Value;
2086  case XmlNodeType.Text:
2087  case XmlNodeType.CDATA:
2088  case XmlNodeType.Whitespace:
2089  case XmlNodeType.SignificantWhitespace:
2090  if (text.Length == 0)
2091  {
2092  text = Value;
2093  }
2094  else
2095  {
2096  if (stringBuilder == null)
2097  {
2098  stringBuilder = new StringBuilder();
2099  stringBuilder.Append(text);
2100  }
2101  stringBuilder.Append(Value);
2102  }
2103  goto case XmlNodeType.ProcessingInstruction;
2104  case XmlNodeType.EntityReference:
2105  if (!CanResolveEntity)
2106  {
2107  break;
2108  }
2109  ResolveEntity();
2110  goto case XmlNodeType.ProcessingInstruction;
2111  case XmlNodeType.ProcessingInstruction:
2112  case XmlNodeType.Comment:
2113  case XmlNodeType.EndEntity:
2114  num = ((AttributeCount != 0) ? ReadAttributeValue() : Read());
2115  continue;
2116  }
2117  break;
2118  }
2119  while (num);
2120  if (stringBuilder != null)
2121  {
2122  return stringBuilder.ToString();
2123  }
2124  return text;
2125  }
2126 
2127  private bool SetupReadElementContentAsXxx(string methodName)
2128  {
2129  if (NodeType != XmlNodeType.Element)
2130  {
2131  throw CreateReadElementContentAsException(methodName);
2132  }
2133  bool isEmptyElement = IsEmptyElement;
2134  Read();
2135  if (isEmptyElement)
2136  {
2137  return false;
2138  }
2139  switch (NodeType)
2140  {
2141  case XmlNodeType.EndElement:
2142  Read();
2143  return false;
2144  case XmlNodeType.Element:
2145  throw new XmlException("Xml_MixedReadElementContentAs", string.Empty, this as IXmlLineInfo);
2146  default:
2147  return true;
2148  }
2149  }
2150 
2151  private void FinishReadElementContentAsXxx()
2152  {
2153  if (NodeType != XmlNodeType.EndElement)
2154  {
2155  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString());
2156  }
2157  Read();
2158  }
2159 
2160  internal static Encoding GetEncoding(XmlReader reader)
2161  {
2162  return GetXmlTextReaderImpl(reader)?.Encoding;
2163  }
2164 
2165  internal static ConformanceLevel GetV1ConformanceLevel(XmlReader reader)
2166  {
2167  return GetXmlTextReaderImpl(reader)?.V1ComformanceLevel ?? ConformanceLevel.Document;
2168  }
2169 
2170  private static XmlTextReaderImpl GetXmlTextReaderImpl(XmlReader reader)
2171  {
2172  XmlTextReaderImpl xmlTextReaderImpl = reader as XmlTextReaderImpl;
2173  if (xmlTextReaderImpl != null)
2174  {
2175  return xmlTextReaderImpl;
2176  }
2177  XmlTextReader xmlTextReader = reader as XmlTextReader;
2178  if (xmlTextReader != null)
2179  {
2180  return xmlTextReader.Impl;
2181  }
2182  XmlValidatingReaderImpl xmlValidatingReaderImpl = reader as XmlValidatingReaderImpl;
2183  if (xmlValidatingReaderImpl != null)
2184  {
2185  return xmlValidatingReaderImpl.ReaderImpl;
2186  }
2187  return (reader as XmlValidatingReader)?.Impl.ReaderImpl;
2188  }
2189 
2198  [global::__DynamicallyInvokable]
2199  public static XmlReader Create(string inputUri)
2200  {
2201  return Create(inputUri, null, null);
2202  }
2203 
2212  [global::__DynamicallyInvokable]
2213  public static XmlReader Create(string inputUri, XmlReaderSettings settings)
2214  {
2215  return Create(inputUri, settings, null);
2216  }
2217 
2228  public static XmlReader Create(string inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
2229  {
2230  if (settings == null)
2231  {
2232  settings = new XmlReaderSettings();
2233  }
2234  return settings.CreateReader(inputUri, inputContext);
2235  }
2236 
2242  [global::__DynamicallyInvokable]
2243  public static XmlReader Create(Stream input)
2244  {
2245  return Create(input, null, string.Empty);
2246  }
2247 
2253  [global::__DynamicallyInvokable]
2254  public static XmlReader Create(Stream input, XmlReaderSettings settings)
2255  {
2256  return Create(input, settings, string.Empty);
2257  }
2258 
2266  public static XmlReader Create(Stream input, XmlReaderSettings settings, string baseUri)
2267  {
2268  if (settings == null)
2269  {
2270  settings = new XmlReaderSettings();
2271  }
2272  return settings.CreateReader(input, null, baseUri, null);
2273  }
2274 
2281  [global::__DynamicallyInvokable]
2282  public static XmlReader Create(Stream input, XmlReaderSettings settings, XmlParserContext inputContext)
2283  {
2284  if (settings == null)
2285  {
2286  settings = new XmlReaderSettings();
2287  }
2288  return settings.CreateReader(input, null, string.Empty, inputContext);
2289  }
2290 
2295  [global::__DynamicallyInvokable]
2296  public static XmlReader Create(TextReader input)
2297  {
2298  return Create(input, null, string.Empty);
2299  }
2300 
2306  [global::__DynamicallyInvokable]
2307  public static XmlReader Create(TextReader input, XmlReaderSettings settings)
2308  {
2309  return Create(input, settings, string.Empty);
2310  }
2311 
2319  public static XmlReader Create(TextReader input, XmlReaderSettings settings, string baseUri)
2320  {
2321  if (settings == null)
2322  {
2323  settings = new XmlReaderSettings();
2324  }
2325  return settings.CreateReader(input, baseUri, null);
2326  }
2327 
2335  [global::__DynamicallyInvokable]
2336  public static XmlReader Create(TextReader input, XmlReaderSettings settings, XmlParserContext inputContext)
2337  {
2338  if (settings == null)
2339  {
2340  settings = new XmlReaderSettings();
2341  }
2342  return settings.CreateReader(input, string.Empty, inputContext);
2343  }
2344 
2351  [global::__DynamicallyInvokable]
2352  public static XmlReader Create(XmlReader reader, XmlReaderSettings settings)
2353  {
2354  if (settings == null)
2355  {
2356  settings = new XmlReaderSettings();
2357  }
2358  return settings.CreateReader(reader);
2359  }
2360 
2361  internal static XmlReader CreateSqlReader(Stream input, XmlReaderSettings settings, XmlParserContext inputContext)
2362  {
2363  if (input == null)
2364  {
2365  throw new ArgumentNullException("input");
2366  }
2367  if (settings == null)
2368  {
2369  settings = new XmlReaderSettings();
2370  }
2371  byte[] array = new byte[CalcBufferSize(input)];
2372  int num = 0;
2373  int num2;
2374  do
2375  {
2376  num2 = input.Read(array, num, array.Length - num);
2377  num += num2;
2378  }
2379  while (num2 > 0 && num < 2);
2380  XmlReader xmlReader;
2381  if (num >= 2 && array[0] == 223 && array[1] == byte.MaxValue)
2382  {
2383  if (inputContext != null)
2384  {
2385  throw new ArgumentException(Res.GetString("XmlBinary_NoParserContext"), "inputContext");
2386  }
2387  xmlReader = new XmlSqlBinaryReader(input, array, num, string.Empty, settings.CloseInput, settings);
2388  }
2389  else
2390  {
2391  xmlReader = new XmlTextReaderImpl(input, array, num, settings, null, string.Empty, inputContext, settings.CloseInput);
2392  }
2393  if (settings.ValidationType != 0)
2394  {
2395  xmlReader = settings.AddValidation(xmlReader);
2396  }
2397  if (settings.Async)
2398  {
2399  xmlReader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(xmlReader);
2400  }
2401  return xmlReader;
2402  }
2403 
2404  internal static int CalcBufferSize(Stream input)
2405  {
2406  int num = 4096;
2407  if (input.CanSeek)
2408  {
2409  long length = input.Length;
2410  if (length < num)
2411  {
2412  num = checked((int)length);
2413  }
2414  else if (length > 65536)
2415  {
2416  num = 8192;
2417  }
2418  }
2419  return num;
2420  }
2421 
2426  [global::__DynamicallyInvokable]
2427  public virtual Task<string> GetValueAsync()
2428  {
2429  throw new NotImplementedException();
2430  }
2431 
2436  [global::__DynamicallyInvokable]
2438  {
2439  if (!CanReadContentAs())
2440  {
2441  throw CreateReadContentAsException("ReadContentAsObject");
2442  }
2443  return await InternalReadContentAsStringAsync().ConfigureAwait(continueOnCapturedContext: false);
2444  }
2445 
2450  [global::__DynamicallyInvokable]
2452  {
2453  if (!CanReadContentAs())
2454  {
2455  throw CreateReadContentAsException("ReadContentAsString");
2456  }
2457  return InternalReadContentAsStringAsync();
2458  }
2459 
2466  [global::__DynamicallyInvokable]
2467  public virtual async Task<object> ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver)
2468  {
2469  if (!CanReadContentAs())
2470  {
2471  throw CreateReadContentAsException("ReadContentAs");
2472  }
2473  string text = await InternalReadContentAsStringAsync().ConfigureAwait(continueOnCapturedContext: false);
2474  if (returnType == typeof(string))
2475  {
2476  return text;
2477  }
2478  try
2479  {
2480  return XmlUntypedConverter.Untyped.ChangeType(text, returnType, (namespaceResolver == null) ? (this as IXmlNamespaceResolver) : namespaceResolver);
2481  }
2482  catch (FormatException innerException)
2483  {
2484  throw new XmlException("Xml_ReadContentAsFormatException", returnType.ToString(), innerException, this as IXmlLineInfo);
2485  }
2486  catch (InvalidCastException innerException2)
2487  {
2488  throw new XmlException("Xml_ReadContentAsFormatException", returnType.ToString(), innerException2, this as IXmlLineInfo);
2489  }
2490  }
2491 
2496  [global::__DynamicallyInvokable]
2498  {
2499  if (await SetupReadElementContentAsXxxAsync("ReadElementContentAsObject").ConfigureAwait(continueOnCapturedContext: false))
2500  {
2501  object value = await ReadContentAsObjectAsync().ConfigureAwait(continueOnCapturedContext: false);
2502  await FinishReadElementContentAsXxxAsync().ConfigureAwait(continueOnCapturedContext: false);
2503  return value;
2504  }
2505  return string.Empty;
2506  }
2507 
2512  [global::__DynamicallyInvokable]
2514  {
2515  if (await SetupReadElementContentAsXxxAsync("ReadElementContentAsString").ConfigureAwait(continueOnCapturedContext: false))
2516  {
2517  string value = await ReadContentAsStringAsync().ConfigureAwait(continueOnCapturedContext: false);
2518  await FinishReadElementContentAsXxxAsync().ConfigureAwait(continueOnCapturedContext: false);
2519  return value;
2520  }
2521  return string.Empty;
2522  }
2523 
2530  [global::__DynamicallyInvokable]
2531  public virtual async Task<object> ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver)
2532  {
2533  if (await SetupReadElementContentAsXxxAsync("ReadElementContentAs").ConfigureAwait(continueOnCapturedContext: false))
2534  {
2535  object value = await ReadContentAsAsync(returnType, namespaceResolver).ConfigureAwait(continueOnCapturedContext: false);
2536  await FinishReadElementContentAsXxxAsync().ConfigureAwait(continueOnCapturedContext: false);
2537  return value;
2538  }
2539  return (returnType == typeof(string)) ? string.Empty : XmlUntypedConverter.Untyped.ChangeType(string.Empty, returnType, namespaceResolver);
2540  }
2541 
2547  [global::__DynamicallyInvokable]
2548  public virtual Task<bool> ReadAsync()
2549  {
2550  throw new NotImplementedException();
2551  }
2552 
2557  [global::__DynamicallyInvokable]
2558  public virtual Task SkipAsync()
2559  {
2560  if (ReadState != ReadState.Interactive)
2561  {
2562  return AsyncHelper.DoneTask;
2563  }
2564  return SkipSubtreeAsync();
2565  }
2566 
2574  [global::__DynamicallyInvokable]
2575  public virtual Task<int> ReadContentAsBase64Async(byte[] buffer, int index, int count)
2576  {
2577  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadContentAsBase64"));
2578  }
2579 
2587  [global::__DynamicallyInvokable]
2588  public virtual Task<int> ReadElementContentAsBase64Async(byte[] buffer, int index, int count)
2589  {
2590  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadElementContentAsBase64"));
2591  }
2592 
2600  [global::__DynamicallyInvokable]
2601  public virtual Task<int> ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
2602  {
2603  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadContentAsBinHex"));
2604  }
2605 
2613  [global::__DynamicallyInvokable]
2614  public virtual Task<int> ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
2615  {
2616  throw new NotSupportedException(Res.GetString("Xml_ReadBinaryContentNotSupported", "ReadElementContentAsBinHex"));
2617  }
2618 
2626  [global::__DynamicallyInvokable]
2627  public virtual Task<int> ReadValueChunkAsync(char[] buffer, int index, int count)
2628  {
2629  throw new NotSupportedException(Res.GetString("Xml_ReadValueChunkNotSupported"));
2630  }
2631 
2636  [global::__DynamicallyInvokable]
2637  public virtual async Task<XmlNodeType> MoveToContentAsync()
2638  {
2639  do
2640  {
2641  switch (NodeType)
2642  {
2643  case XmlNodeType.Attribute:
2644  MoveToElement();
2645  break;
2646  case XmlNodeType.Element:
2647  case XmlNodeType.Text:
2648  case XmlNodeType.CDATA:
2649  case XmlNodeType.EntityReference:
2650  case XmlNodeType.EndElement:
2651  case XmlNodeType.EndEntity:
2652  break;
2653  default:
2654  continue;
2655  }
2656  return NodeType;
2657  }
2658  while (await ReadAsync().ConfigureAwait(continueOnCapturedContext: false));
2659  return NodeType;
2660  }
2661 
2666  [global::__DynamicallyInvokable]
2667  public virtual async Task<string> ReadInnerXmlAsync()
2668  {
2669  if (ReadState != ReadState.Interactive)
2670  {
2671  return string.Empty;
2672  }
2673  if (NodeType != XmlNodeType.Attribute && NodeType != XmlNodeType.Element)
2674  {
2675  await ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
2676  return string.Empty;
2677  }
2679  XmlWriter xtw = CreateWriterForInnerOuterXml(sw);
2680  try
2681  {
2682  if (NodeType == XmlNodeType.Attribute)
2683  {
2684  ((XmlTextWriter)xtw).QuoteChar = QuoteChar;
2685  WriteAttributeValue(xtw);
2686  }
2687  if (NodeType == XmlNodeType.Element)
2688  {
2689  await WriteNodeAsync(xtw, defattr: false).ConfigureAwait(continueOnCapturedContext: false);
2690  }
2691  }
2692  finally
2693  {
2694  xtw.Close();
2695  }
2696  return sw.ToString();
2697  }
2698 
2699  private async Task WriteNodeAsync(XmlWriter xtw, bool defattr)
2700  {
2701  int d = (NodeType == XmlNodeType.None) ? (-1) : Depth;
2702  while (await ReadAsync().ConfigureAwait(continueOnCapturedContext: false) && d < Depth)
2703  {
2704  switch (NodeType)
2705  {
2706  case XmlNodeType.Element:
2708  ((XmlTextWriter)xtw).QuoteChar = QuoteChar;
2709  xtw.WriteAttributes(this, defattr);
2710  if (IsEmptyElement)
2711  {
2712  xtw.WriteEndElement();
2713  }
2714  break;
2715  case XmlNodeType.Text:
2716  xtw.WriteString(await GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
2717  break;
2718  case XmlNodeType.Whitespace:
2719  case XmlNodeType.SignificantWhitespace:
2720  xtw.WriteWhitespace(await GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
2721  break;
2722  case XmlNodeType.CDATA:
2723  xtw.WriteCData(Value);
2724  break;
2725  case XmlNodeType.EntityReference:
2726  xtw.WriteEntityRef(Name);
2727  break;
2728  case XmlNodeType.ProcessingInstruction:
2729  case XmlNodeType.XmlDeclaration:
2731  break;
2732  case XmlNodeType.DocumentType:
2733  xtw.WriteDocType(Name, GetAttribute("PUBLIC"), GetAttribute("SYSTEM"), Value);
2734  break;
2735  case XmlNodeType.Comment:
2736  xtw.WriteComment(Value);
2737  break;
2738  case XmlNodeType.EndElement:
2739  xtw.WriteFullEndElement();
2740  break;
2741  }
2742  }
2743  if (d == Depth && NodeType == XmlNodeType.EndElement)
2744  {
2745  await ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
2746  }
2747  }
2748 
2753  [global::__DynamicallyInvokable]
2754  public virtual async Task<string> ReadOuterXmlAsync()
2755  {
2756  if (ReadState != ReadState.Interactive)
2757  {
2758  return string.Empty;
2759  }
2760  if (NodeType != XmlNodeType.Attribute && NodeType != XmlNodeType.Element)
2761  {
2762  await ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
2763  return string.Empty;
2764  }
2766  XmlWriter xmlWriter = CreateWriterForInnerOuterXml(stringWriter);
2767  try
2768  {
2769  if (NodeType == XmlNodeType.Attribute)
2770  {
2772  WriteAttributeValue(xmlWriter);
2773  xmlWriter.WriteEndAttribute();
2774  }
2775  else
2776  {
2777  xmlWriter.WriteNode(this, defattr: false);
2778  }
2779  }
2780  finally
2781  {
2782  xmlWriter.Close();
2783  }
2784  return stringWriter.ToString();
2785  }
2786 
2787  private async Task<bool> SkipSubtreeAsync()
2788  {
2789  MoveToElement();
2790  if (NodeType == XmlNodeType.Element && !IsEmptyElement)
2791  {
2792  int depth = Depth;
2793  while (await ReadAsync().ConfigureAwait(continueOnCapturedContext: false) && depth < Depth)
2794  {
2795  }
2796  if (NodeType == XmlNodeType.EndElement)
2797  {
2798  return await ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
2799  }
2800  return false;
2801  }
2802  return await ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
2803  }
2804 
2805  internal async Task<string> InternalReadContentAsStringAsync()
2806  {
2807  string value = string.Empty;
2808  StringBuilder sb = null;
2809  bool flag;
2810  do
2811  {
2812  switch (NodeType)
2813  {
2814  case XmlNodeType.Attribute:
2815  return Value;
2816  case XmlNodeType.Text:
2817  case XmlNodeType.CDATA:
2818  case XmlNodeType.Whitespace:
2819  case XmlNodeType.SignificantWhitespace:
2820  if (value.Length == 0)
2821  {
2822  value = await GetValueAsync().ConfigureAwait(continueOnCapturedContext: false);
2823  }
2824  else
2825  {
2826  if (sb == null)
2827  {
2828  sb = new StringBuilder();
2829  sb.Append(value);
2830  }
2831  StringBuilder stringBuilder = sb;
2832  stringBuilder.Append(await GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
2833  }
2834  goto case XmlNodeType.ProcessingInstruction;
2835  case XmlNodeType.EntityReference:
2836  if (!CanResolveEntity)
2837  {
2838  break;
2839  }
2840  ResolveEntity();
2841  goto case XmlNodeType.ProcessingInstruction;
2842  case XmlNodeType.ProcessingInstruction:
2843  case XmlNodeType.Comment:
2844  case XmlNodeType.EndEntity:
2845  flag = ((AttributeCount == 0) ? (await ReadAsync().ConfigureAwait(continueOnCapturedContext: false)) : ReadAttributeValue());
2846  continue;
2847  }
2848  break;
2849  }
2850  while (flag);
2851  return (sb == null) ? value : sb.ToString();
2852  }
2853 
2854  private async Task<bool> SetupReadElementContentAsXxxAsync(string methodName)
2855  {
2856  if (NodeType != XmlNodeType.Element)
2857  {
2858  throw CreateReadElementContentAsException(methodName);
2859  }
2860  bool isEmptyElement = IsEmptyElement;
2861  await ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
2862  if (isEmptyElement)
2863  {
2864  return false;
2865  }
2866  switch (NodeType)
2867  {
2868  case XmlNodeType.EndElement:
2869  await ReadAsync().ConfigureAwait(continueOnCapturedContext: false);
2870  return false;
2871  case XmlNodeType.Element:
2872  throw new XmlException("Xml_MixedReadElementContentAs", string.Empty, this as IXmlLineInfo);
2873  default:
2874  return true;
2875  }
2876  }
2877 
2878  private Task FinishReadElementContentAsXxxAsync()
2879  {
2880  if (NodeType != XmlNodeType.EndElement)
2881  {
2882  throw new XmlException("Xml_InvalidNodeType", NodeType.ToString());
2883  }
2884  return ReadAsync();
2885  }
2886 
2888  [global::__DynamicallyInvokable]
2889  protected XmlReader()
2890  {
2891  }
2892  }
2893 }
virtual long ReadContentAsLong()
Reads the text content at the current position as a 64-bit signed integer.
Definition: XmlReader.cs:629
Represents a character encoding.To browse the .NET Framework source code for this type,...
Definition: Encoding.cs:15
Provides an interface to enable a class to return line and position information.
Definition: IXmlLineInfo.cs:5
abstract void ResolveEntity()
When overridden in a derived class, resolves the entity reference for EntityReference nodes.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Definition: CultureInfo.cs:263
abstract string BaseURI
When overridden in a derived class, gets the base URI of the current node.
Definition: XmlReader.cs:215
virtual bool ReadElementContentAsBoolean()
Reads the current element and returns the contents as a T:System.Boolean object.
Definition: XmlReader.cs:738
bool Async
Gets or sets whether asynchronous T:System.Xml.XmlReader methods can be used on a particular T:System...
static DateTime ToDateTime(string s)
Converts the T:System.String to a T:System.DateTime equivalent.
Definition: XmlConvert.cs:1386
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static float ToSingle(string s)
Converts the T:System.String to a T:System.Single equivalent.
Definition: XmlConvert.cs:1144
abstract string LookupNamespace(string prefix)
When overridden in a derived class, resolves a namespace prefix in the current element's scope.
The exception that is thrown when there is an attempt to dereference a null object reference.
abstract int Read([In] [Out] byte[] buffer, int offset, int count)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances th...
virtual bool CanReadBinaryContent
Gets a value indicating whether the T:System.Xml.XmlReader implements the binary content read methods...
Definition: XmlReader.cs:398
virtual bool IsDefault
When overridden in a derived class, gets a value indicating whether the current node is an attribute ...
Definition: XmlReader.cs:237
Defines the post-schema-validation infoset of a validated XML node.
virtual bool HasValue
When overridden in a derived class, gets a value indicating whether the current node can have a P:Sys...
Definition: XmlReader.cs:164
Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Un...
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Configures an awaiter used to await this T:System.Threading.Tasks.Task`1.
Definition: Task.cs:393
override string Add(string key)
Atomizes the specified string and adds it to the NameTable.
Definition: NameTable.cs:46
virtual int ReadContentAsBinHex(byte[] buffer, int index, int count)
Reads the content and returns the BinHex decoded binary bytes.
Definition: XmlReader.cs:1227
abstract bool MoveToElement()
When overridden in a derived class, moves to the element that contains the current attribute node.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
virtual Task< string > ReadContentAsStringAsync()
Asynchronously reads the text content at the current position as a T:System.String object.
Definition: XmlReader.cs:2451
virtual decimal ReadContentAsDecimal()
Reads the text content at the current position as a T:System.Decimal object.
Definition: XmlReader.cs:585
virtual DateTime ReadElementContentAsDateTime(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:791
abstract string LocalName
When overridden in a derived class, gets the local name of the current node.
Definition: XmlReader.cs:133
Implements a T:System.IO.TextWriter for writing information to a string. The information is stored in...
Definition: StringWriter.cs:13
abstract bool CanSeek
When overridden in a derived class, gets a value indicating whether the current stream supports seeki...
Definition: Stream.cs:587
static XmlReader Create(Stream input, XmlReaderSettings settings)
Creates a new T:System.Xml.XmlReader instance with the specified stream and settings.
Definition: XmlReader.cs:2254
virtual bool ReadElementContentAsBoolean(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:759
virtual float ReadElementContentAsFloat(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:859
static XmlReader Create(string inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
Creates a new T:System.Xml.XmlReader instance by using the specified URI, settings,...
Definition: XmlReader.cs:2228
virtual void Skip()
Skips the children of the current node.
Definition: XmlReader.cs:1159
EditorBrowsableState
Specifies the browsable state of a property or method from within an editor.
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Definition: IDisposable.cs:8
virtual Task< bool > ReadAsync()
Asynchronously reads the next node from the stream.
Definition: XmlReader.cs:2548
static long ToInt64(string s)
Converts the T:System.String to a T:System.Int64 equivalent.
Definition: XmlConvert.cs:1021
Definition: __Canon.cs:3
virtual long ReadElementContentAsLong()
Reads the current element and returns the contents as a 64-bit signed integer.
Definition: XmlReader.cs:940
The exception that is thrown when the value of an argument is outside the allowable range of values a...
The exception that is thrown for invalid casting or explicit conversion.
virtual DateTime ReadElementContentAsDateTime()
Reads the current element and returns the contents as a T:System.DateTime object.
Definition: XmlReader.cs:771
override string ToString()
Returns a String representing the name of the current Type.
Definition: Type.cs:2788
abstract void WriteEndAttribute()
When overridden in a derived class, closes the previous M:System.Xml.XmlWriter.WriteStartAttribute(Sy...
virtual string ReadElementContentAsString()
Reads the current element and returns the contents as a T:System.String object.
Definition: XmlReader.cs:974
virtual Task< string > GetValueAsync()
Asynchronously gets the value of the current node.
Definition: XmlReader.cs:2427
abstract string NamespaceURI
When overridden in a derived class, gets the namespace URI (as defined in the W3C Namespace specifica...
Definition: XmlReader.cs:143
void WriteStartAttribute(string localName, string ns)
Writes the start of an attribute with the specified local name and namespace URI.
Definition: XmlWriter.cs:199
abstract void WriteWhitespace(string ws)
When overridden in a derived class, writes out the given white space.
virtual char QuoteChar
When overridden in a derived class, gets the quotation mark character used to enclose the value of an...
Definition: XmlReader.cs:248
static XmlReader Create(XmlReader reader, XmlReaderSettings settings)
Creates a new T:System.Xml.XmlReader instance by using the specified XML reader and settings.
Definition: XmlReader.cs:2352
virtual async Task< object > ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver)
Asynchronously reads the content as an object of the type specified.
Definition: XmlReader.cs:2467
virtual bool ReadToNextSibling(string name)
Advances the XmlReader to the next sibling element with the specified qualified name.
Definition: XmlReader.cs:1698
virtual XmlNodeType MoveToContent()
Checks whether the current node is a content (non-white space text, CDATA, Element,...
Definition: XmlReader.cs:1311
abstract bool MoveToAttribute(string name)
When overridden in a derived class, moves to the attribute with the specified P:System....
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
virtual object ReadElementContentAsObject(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:725
XmlNodeType
Specifies the type of node.
Definition: XmlNodeType.cs:5
virtual bool ReadToNextSibling(string localName, string namespaceURI)
Advances the XmlReader to the next sibling element with the specified local name and namespace URI.
Definition: XmlReader.cs:1728
virtual Task< int > ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
Asynchronously reads the content and returns the BinHex decoded binary bytes.
Definition: XmlReader.cs:2601
abstract void WriteString(string text)
When overridden in a derived class, writes the given text content.
Specifies a set of features to support on the T:System.Xml.XmlReader object created by the Overload:S...
static bool IsNameToken(string str)
Returns a value indicating whether or not the string argument is a valid XML name token.
Definition: XmlReader.cs:1776
static XmlReader Create(TextReader input, XmlReaderSettings settings)
Creates a new T:System.Xml.XmlReader instance by using the specified text reader and settings.
Definition: XmlReader.cs:2307
virtual Task< int > ReadValueChunkAsync(char[] buffer, int index, int count)
Asynchronously reads large streams of text embedded in an XML document.
Definition: XmlReader.cs:2627
virtual Task SkipAsync()
Asynchronously skips the children of the current node.
Definition: XmlReader.cs:2558
abstract XmlNodeType NodeType
When overridden in a derived class, gets the type of the current node.
Definition: XmlReader.cs:94
Represents a writer that provides a fast, non-cached, forward-only way to generate streams or files t...
Definition: XmlWriter.cs:12
Provides all the context information required by the T:System.Xml.XmlReader to parse an XML fragment.
Represents a reader that provides fast, noncached, forward-only access to XML data....
Definition: XmlReader.cs:15
virtual IXmlSchemaInfo SchemaInfo
Gets the schema information that has been assigned to the current node as a result of schema validati...
Definition: XmlReader.cs:279
abstract bool MoveToFirstAttribute()
When overridden in a derived class, moves to the first attribute.
virtual int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
Reads the element and decodes the BinHex content.
Definition: XmlReader.cs:1245
Implements a single-threaded T:System.Xml.XmlNameTable.
Definition: NameTable.cs:5
abstract bool EOF
When overridden in a derived class, gets a value indicating whether the reader is positioned at the e...
Definition: XmlReader.cs:353
virtual string Name
When overridden in a derived class, gets the qualified name of the current node.
Definition: XmlReader.cs:116
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
override string ToString()
Returns a string containing the characters written to the current StringWriter so far.
virtual bool HasAttributes
Gets a value indicating whether the current node has any attributes.
Definition: XmlReader.cs:426
virtual async Task< string > ReadElementContentAsStringAsync()
Asynchronously reads the current element and returns the contents as a T:System.String object.
Definition: XmlReader.cs:2513
static XmlReader Create(TextReader input, XmlReaderSettings settings, XmlParserContext inputContext)
Creates a new T:System.Xml.XmlReader instance by using the specified text reader, settings,...
Definition: XmlReader.cs:2336
virtual bool IsStartElement()
Calls M:System.Xml.XmlReader.MoveToContent and tests if the current content node is a start tag or em...
Definition: XmlReader.cs:1515
The exception that is thrown when the format of an argument is invalid, or when a composite format st...
static XmlReader Create(Stream input)
Creates a new T:System.Xml.XmlReader instance using the specified stream with default settings.
Definition: XmlReader.cs:2243
virtual bool ReadContentAsBoolean()
Reads the text content at the current position as a Boolean.
Definition: XmlReader.cs:478
virtual object ReadContentAsObject()
Reads the text content at the current position as an T:System.Object.
Definition: XmlReader.cs:463
virtual XmlReader ReadSubtree()
Returns a new XmlReader instance that can be used to read the current node, and all its descendants.
Definition: XmlReader.cs:1954
ConformanceLevel
Specifies the amount of input or output checking that T:System.Xml.XmlReader and T:System....
abstract void WriteFullEndElement()
When overridden in a derived class, closes one element and pops the corresponding namespace scope.
abstract int Depth
When overridden in a derived class, gets the depth of the current node in the XML document.
Definition: XmlReader.cs:205
virtual void MoveToAttribute(int i)
When overridden in a derived class, moves to the attribute with the specified index.
Definition: XmlReader.cs:1099
virtual void ReadEndElement()
Checks that the current content node is an end tag and advances the reader to the next node.
Definition: XmlReader.cs:1500
virtual async Task< string > ReadInnerXmlAsync()
Asynchronously reads all the content, including markup, as a string.
Definition: XmlReader.cs:2667
Represents a writer that provides a fast, non-cached, forward-only way of generating streams or files...
virtual string ReadElementString(string localname, string ns)
Checks that the P:System.Xml.XmlReader.LocalName and P:System.Xml.XmlReader.NamespaceURI properties o...
Definition: XmlReader.cs:1465
Resolves, adds, and removes namespaces to a collection and provides scope management for these namesp...
void Dispose()
Releases all resources used by the current instance of the T:System.Xml.XmlReader class.
Definition: XmlReader.cs:1966
virtual float ReadElementContentAsFloat()
Reads the current element and returns the contents as single-precision floating-point number.
Definition: XmlReader.cs:838
virtual XmlReaderSettings Settings
Gets the T:System.Xml.XmlReaderSettings object used to create this T:System.Xml.XmlReader instance.
Definition: XmlReader.cs:81
virtual bool ReadToDescendant(string name)
Advances the T:System.Xml.XmlReader to the next descendant element with the specified qualified name.
Definition: XmlReader.cs:1618
virtual bool IsStartElement(string name)
Calls M:System.Xml.XmlReader.MoveToContent and tests if the current content node is a start tag or em...
Definition: XmlReader.cs:1527
virtual int ReadElementContentAsBase64(byte[] buffer, int index, int count)
Reads the element and decodes the Base64 content.
Definition: XmlReader.cs:1210
virtual string ReadElementString(string name)
Checks that the P:System.Xml.XmlReader.Name property of the element found matches the given string be...
Definition: XmlReader.cs:1431
virtual async Task< string > ReadOuterXmlAsync()
Asynchronously reads the content, including markup, representing this node and all its children.
Definition: XmlReader.cs:2754
virtual DateTimeOffset ReadContentAsDateTimeOffset()
Reads the text content at the current position as a T:System.DateTimeOffset object.
Definition: XmlReader.cs:519
abstract void WriteCData(string text)
When overridden in a derived class, writes out a <![CDATA[...]]> block containing the specified text.
static bool IsName(string str)
Returns a value indicating whether the string argument is a valid XML name.
Definition: XmlReader.cs:1761
virtual void ReadStartElement(string name)
Checks that the current content node is an element with the given P:System.Xml.XmlReader....
Definition: XmlReader.cs:1354
virtual object ReadElementContentAsObject()
Reads the current element and returns the contents as an T:System.Object.
Definition: XmlReader.cs:704
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
abstract void WriteDocType(string name, string pubid, string sysid, string subset)
When overridden in a derived class, writes the DOCTYPE declaration with the specified name and option...
virtual async Task< object > ReadElementContentAsObjectAsync()
Asynchronously reads the current element and returns the contents as an T:System.Object.
Definition: XmlReader.cs:2497
virtual bool IsStartElement(string localname, string ns)
Calls M:System.Xml.XmlReader.MoveToContent and tests if the current content node is a start tag or em...
Definition: XmlReader.cs:1544
virtual int ReadValueChunk(char[] buffer, int index, int count)
Reads large streams of text embedded in an XML document.
Definition: XmlReader.cs:1262
abstract void WriteEndElement()
When overridden in a derived class, closes one element and pops the corresponding namespace scope.
Table of atomized string objects.
Definition: XmlNameTable.cs:5
virtual decimal ReadElementContentAsDecimal(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:893
virtual object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver, string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:1041
virtual bool CanReadValueChunk
Gets a value indicating whether the T:System.Xml.XmlReader implements the M:System....
Definition: XmlReader.cs:412
ReadState
Specifies the state of the reader.
Definition: ReadState.cs:5
virtual long ReadElementContentAsLong(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:961
abstract bool MoveToNextAttribute()
When overridden in a derived class, moves to the next attribute.
virtual bool CanResolveEntity
Gets a value indicating whether this reader can parse and resolve entities.
Definition: XmlReader.cs:384
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
virtual double ReadElementContentAsDouble(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:825
virtual object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver)
Reads the element content as the requested type.
Definition: XmlReader.cs:1012
Returns detailed information about the last exception.
Definition: XmlException.cs:12
abstract string GetAttribute(string name)
When overridden in a derived class, gets the value of the attribute with the specified P:System....
virtual int ReadElementContentAsInt()
Reads the current element and returns the contents as a 32-bit signed integer.
Definition: XmlReader.cs:906
abstract void WriteEntityRef(string name)
When overridden in a derived class, writes out an entity reference as &name;.
abstract long Length
When overridden in a derived class, gets the length in bytes of the stream.
Definition: Stream.cs:621
abstract bool Read()
When overridden in a derived class, reads the next node from the stream.
virtual void ReadStartElement()
Checks that the current node is an element and advances the reader to the next node.
Definition: XmlReader.cs:1340
virtual void Close()
When overridden in a derived class, closes this stream and the underlying stream.
Definition: XmlWriter.cs:353
virtual string ReadElementString()
Reads a text-only element. However, we recommend that you use the M:System.Xml.XmlReader....
Definition: XmlReader.cs:1397
virtual Task< int > ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
Asynchronously reads the element and decodes the BinHex content.
Definition: XmlReader.cs:2614
abstract string Prefix
When overridden in a derived class, gets the namespace prefix associated with the current node.
Definition: XmlReader.cs:153
virtual void WriteNode(XmlReader reader, bool defattr)
When overridden in a derived class, copies everything from the reader to the writer and moves the rea...
Definition: XmlWriter.cs:596
virtual string XmlLang
When overridden in a derived class, gets the current xml:lang scope.
Definition: XmlReader.cs:268
virtual float ReadContentAsFloat()
Reads the text content at the current position as a single-precision floating point number.
Definition: XmlReader.cs:563
virtual int ReadElementContentAsInt(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:927
virtual bool ReadToFollowing(string name)
Reads until an element with the specified qualified name is found.
Definition: XmlReader.cs:1564
virtual double ReadContentAsDouble()
Reads the text content at the current position as a double-precision floating-point number.
Definition: XmlReader.cs:541
virtual bool ReadToFollowing(string localName, string namespaceURI)
Reads until an element with the specified local name and namespace URI is found.
Definition: XmlReader.cs:1589
Represents a reader that can read a sequential series of characters.
Definition: TextReader.cs:14
Provides read-only access to a set of prefix and namespace mappings.
virtual DateTime ReadContentAsDateTime()
Reads the text content at the current position as a T:System.DateTime object.
Definition: XmlReader.cs:499
static bool ToBoolean(string s)
Converts the T:System.String to a T:System.Boolean equivalent.
Definition: XmlConvert.cs:837
abstract bool IsEmptyElement
When overridden in a derived class, gets a value indicating whether the current node is an empty elem...
Definition: XmlReader.cs:226
virtual string ReadString()
When overridden in a derived class, reads the contents of an element or text node as a string....
Definition: XmlReader.cs:1272
virtual object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver)
Reads the content as an object of the type specified.
Definition: XmlReader.cs:672
virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.Xml.XmlReader and optionally releases the manag...
Definition: XmlReader.cs:1976
abstract void WriteComment(string text)
When overridden in a derived class, writes out a comment <!–...–> containing the specified text.
virtual void WriteAttributes(XmlReader reader, bool defattr)
When overridden in a derived class, writes out all the attributes found at the current position in th...
Definition: XmlWriter.cs:544
virtual int ReadContentAsInt()
Reads the text content at the current position as a 32-bit signed integer.
Definition: XmlReader.cs:607
bool Namespaces
Gets or sets a value indicating whether to do namespace support.
virtual string ReadElementContentAsString(string localName, string namespaceURI)
Checks that the specified local name and namespace URI matches that of the current element,...
Definition: XmlReader.cs:995
virtual async Task< object > ReadContentAsObjectAsync()
Asynchronously reads the text content at the current position as an T:System.Object.
Definition: XmlReader.cs:2437
static decimal ToDecimal(string s)
Converts the T:System.String to a T:System.Decimal equivalent.
Definition: XmlConvert.cs:910
static XmlReader Create(TextReader input, XmlReaderSettings settings, string baseUri)
Creates a new T:System.Xml.XmlReader instance by using the specified text reader, settings,...
Definition: XmlReader.cs:2319
virtual int ReadContentAsBase64(byte[] buffer, int index, int count)
Reads the content and returns the Base64 decoded binary bytes.
Definition: XmlReader.cs:1192
The exception that is thrown when a method call is invalid for the object's current state.
ValidationType ValidationType
Gets or sets a value indicating whether the T:System.Xml.XmlReader will perform validation or type as...
virtual decimal ReadElementContentAsDecimal()
Reads the current element and returns the contents as a T:System.Decimal object.
Definition: XmlReader.cs:872
virtual Task< int > ReadElementContentAsBase64Async(byte[] buffer, int index, int count)
Asynchronously reads the element and decodes the Base64 content.
Definition: XmlReader.cs:2588
virtual Task< int > ReadContentAsBase64Async(byte[] buffer, int index, int count)
Asynchronously reads the content and returns the Base64 decoded binary bytes.
Definition: XmlReader.cs:2575
abstract void WriteProcessingInstruction(string name, string text)
When overridden in a derived class, writes out a processing instruction with a space between the name...
virtual async Task< XmlNodeType > MoveToContentAsync()
Asynchronously checks whether the current node is a content node. If the node is not a content node,...
Definition: XmlReader.cs:2637
XmlSpace
Specifies the current xml:space scope.
Definition: XmlSpace.cs:5
virtual string ReadContentAsString()
Reads the text content at the current position as a T:System.String object.
Definition: XmlReader.cs:651
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
bool CloseInput
Gets or sets a value indicating whether the underlying stream or T:System.IO.TextReader should be clo...
virtual async Task< object > ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver)
Asynchronously reads the element content as the requested type.
Definition: XmlReader.cs:2531
abstract int AttributeCount
When overridden in a derived class, gets the number of attributes on the current node.
Definition: XmlReader.cs:299
abstract string Value
When overridden in a derived class, gets the text value of the current node.
Definition: XmlReader.cs:195
static DateTimeOffset ToDateTimeOffset(string s)
Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent.
Definition: XmlConvert.cs:1461
static int ToInt32(string s)
Converts the T:System.String to a T:System.Int32 equivalent.
Definition: XmlConvert.cs:997
abstract bool ReadAttributeValue()
When overridden in a derived class, parses the attribute value into one or more Text,...
virtual bool ReadToDescendant(string localName, string namespaceURI)
Advances the T:System.Xml.XmlReader to the next descendant element with the specified local name and ...
Definition: XmlReader.cs:1656
static XmlReader Create(Stream input, XmlReaderSettings settings, string baseUri)
Creates a new T:System.Xml.XmlReader instance using the specified stream, base URI,...
Definition: XmlReader.cs:2266
static XmlReader Create(TextReader input)
Creates a new T:System.Xml.XmlReader instance by using the specified text reader.
Definition: XmlReader.cs:2296
The exception that is thrown when a requested method or operation is not implemented.
static XmlReader Create(string inputUri)
Creates a new T:System.Xml.XmlReader instance with specified URI.
Definition: XmlReader.cs:2199
Provides the base class for value types.
Definition: ValueType.cs:12
XmlDateTimeSerializationMode
Specifies how to treat the time value when converting between string and T:System....
XmlReader()
Initializes a new instance of the XmlReader class.
Definition: XmlReader.cs:2889
virtual void ReadStartElement(string localname, string ns)
Checks that the current content node is an element with the given P:System.Xml.XmlReader....
Definition: XmlReader.cs:1374
virtual double ReadElementContentAsDouble()
Reads the current element and returns the contents as a double-precision floating-point number.
Definition: XmlReader.cs:804
virtual void Close()
When overridden in a derived class, changes the P:System.Xml.XmlReader.ReadState to F:System....
Definition: XmlReader.cs:1152
static XmlReader Create(string inputUri, XmlReaderSettings settings)
Creates a new T:System.Xml.XmlReader instance by using the specified URI and settings.
Definition: XmlReader.cs:2213
virtual string ReadOuterXml()
When overridden in a derived class, reads the content, including markup, representing this node and a...
Definition: XmlReader.cs:1894
static XmlReader Create(Stream input, XmlReaderSettings settings, XmlParserContext inputContext)
Creates a new T:System.Xml.XmlReader instance using the specified stream, settings,...
Definition: XmlReader.cs:2282
Encodes and decodes XML names, and provides methods for converting between common language runtime ty...
Definition: XmlConvert.cs:11
Represents an asynchronous operation that can return a value.
Definition: Task.cs:18
bool IsDefault
Gets a value indicating if this validated XML node was set as the result of a default being applied d...
void WriteStartElement(string localName, string ns)
When overridden in a derived class, writes the specified start tag and associates it with the given n...
Definition: XmlWriter.cs:110
static double ToDouble(string s)
Converts the T:System.String to a T:System.Double equivalent.
Definition: XmlConvert.cs:1197
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....
Definition: Stream.cs:16
virtual string ReadInnerXml()
When overridden in a derived class, reads all the content, including markup, as a string.
Definition: XmlReader.cs:1790