mscorlib(4.0.0.0) API with additions
XmlWriter.cs
2 using System.IO;
3 using System.Text;
5 using System.Xml.Schema;
6 using System.Xml.XPath;
7 
8 namespace System.Xml
9 {
11  [global::__DynamicallyInvokable]
12  public abstract class XmlWriter : IDisposable
13  {
14  private char[] writeNodeBuffer;
15 
16  private const int WriteNodeBufferSize = 1024;
17 
21  [global::__DynamicallyInvokable]
22  public virtual XmlWriterSettings Settings
23  {
24  [global::__DynamicallyInvokable]
25  get
26  {
27  return null;
28  }
29  }
30 
34  [global::__DynamicallyInvokable]
35  public abstract WriteState WriteState
36  {
37  [global::__DynamicallyInvokable]
38  get;
39  }
40 
50  [global::__DynamicallyInvokable]
51  public virtual XmlSpace XmlSpace
52  {
53  [global::__DynamicallyInvokable]
54  get
55  {
56  return XmlSpace.Default;
57  }
58  }
59 
63  [global::__DynamicallyInvokable]
64  public virtual string XmlLang
65  {
66  [global::__DynamicallyInvokable]
67  get
68  {
69  return string.Empty;
70  }
71  }
72 
76  [global::__DynamicallyInvokable]
77  public abstract void WriteStartDocument();
78 
83  [global::__DynamicallyInvokable]
84  public abstract void WriteStartDocument(bool standalone);
85 
89  [global::__DynamicallyInvokable]
90  public abstract void WriteEndDocument();
91 
100  [global::__DynamicallyInvokable]
101  public abstract void WriteDocType(string name, string pubid, string sysid, string subset);
102 
109  [global::__DynamicallyInvokable]
110  public void WriteStartElement(string localName, string ns)
111  {
112  WriteStartElement(null, localName, ns);
113  }
114 
122  [global::__DynamicallyInvokable]
123  public abstract void WriteStartElement(string prefix, string localName, string ns);
124 
130  [global::__DynamicallyInvokable]
131  public void WriteStartElement(string localName)
132  {
133  WriteStartElement(null, localName, null);
134  }
135 
139  [global::__DynamicallyInvokable]
140  public abstract void WriteEndElement();
141 
144  [global::__DynamicallyInvokable]
145  public abstract void WriteFullEndElement();
146 
154  [global::__DynamicallyInvokable]
155  public void WriteAttributeString(string localName, string ns, string value)
156  {
157  WriteStartAttribute(null, localName, ns);
158  WriteString(value);
160  }
161 
168  [global::__DynamicallyInvokable]
169  public void WriteAttributeString(string localName, string value)
170  {
171  WriteStartAttribute(null, localName, null);
172  WriteString(value);
174  }
175 
185  [global::__DynamicallyInvokable]
186  public void WriteAttributeString(string prefix, string localName, string ns, string value)
187  {
188  WriteStartAttribute(prefix, localName, ns);
189  WriteString(value);
191  }
192 
198  [global::__DynamicallyInvokable]
199  public void WriteStartAttribute(string localName, string ns)
200  {
201  WriteStartAttribute(null, localName, ns);
202  }
203 
210  [global::__DynamicallyInvokable]
211  public abstract void WriteStartAttribute(string prefix, string localName, string ns);
212 
218  [global::__DynamicallyInvokable]
219  public void WriteStartAttribute(string localName)
220  {
221  WriteStartAttribute(null, localName, null);
222  }
223 
226  [global::__DynamicallyInvokable]
227  public abstract void WriteEndAttribute();
228 
233  [global::__DynamicallyInvokable]
234  public abstract void WriteCData(string text);
235 
240  [global::__DynamicallyInvokable]
241  public abstract void WriteComment(string text);
242 
249  [global::__DynamicallyInvokable]
250  public abstract void WriteProcessingInstruction(string name, string text);
251 
257  [global::__DynamicallyInvokable]
258  public abstract void WriteEntityRef(string name);
259 
264  [global::__DynamicallyInvokable]
265  public abstract void WriteCharEntity(char ch);
266 
271  [global::__DynamicallyInvokable]
272  public abstract void WriteWhitespace(string ws);
273 
278  [global::__DynamicallyInvokable]
279  public abstract void WriteString(string text);
280 
286  [global::__DynamicallyInvokable]
287  public abstract void WriteSurrogateCharEntity(char lowChar, char highChar);
288 
299  [global::__DynamicallyInvokable]
300  public abstract void WriteChars(char[] buffer, int index, int count);
301 
311  [global::__DynamicallyInvokable]
312  public abstract void WriteRaw(char[] buffer, int index, int count);
313 
319  [global::__DynamicallyInvokable]
320  public abstract void WriteRaw(string data);
321 
331  [global::__DynamicallyInvokable]
332  public abstract void WriteBase64(byte[] buffer, int index, int count);
333 
344  [global::__DynamicallyInvokable]
345  public virtual void WriteBinHex(byte[] buffer, int index, int count)
346  {
347  BinHexEncoder.Encode(buffer, index, count, this);
348  }
349 
353  public virtual void Close()
354  {
355  }
356 
359  [global::__DynamicallyInvokable]
360  public abstract void Flush();
361 
368  [global::__DynamicallyInvokable]
369  public abstract string LookupPrefix(string ns);
370 
376  [global::__DynamicallyInvokable]
377  public virtual void WriteNmToken(string name)
378  {
379  if (name == null || name.Length == 0)
380  {
381  throw new ArgumentException(Res.GetString("Xml_EmptyName"));
382  }
383  WriteString(XmlConvert.VerifyNMTOKEN(name, ExceptionType.ArgumentException));
384  }
385 
391  [global::__DynamicallyInvokable]
392  public virtual void WriteName(string name)
393  {
394  WriteString(XmlConvert.VerifyQName(name, ExceptionType.ArgumentException));
395  }
396 
404  [global::__DynamicallyInvokable]
405  public virtual void WriteQualifiedName(string localName, string ns)
406  {
407  if (ns != null && ns.Length > 0)
408  {
409  string text = LookupPrefix(ns);
410  if (text == null)
411  {
412  throw new ArgumentException(Res.GetString("Xml_UndefNamespace", ns));
413  }
414  WriteString(text);
415  WriteString(":");
416  }
417  WriteString(localName);
418  }
419 
427  [global::__DynamicallyInvokable]
428  public virtual void WriteValue(object value)
429  {
430  if (value == null)
431  {
432  throw new ArgumentNullException("value");
433  }
434  WriteString(XmlUntypedConverter.Untyped.ToString(value, null));
435  }
436 
441  [global::__DynamicallyInvokable]
442  public virtual void WriteValue(string value)
443  {
444  if (value != null)
445  {
446  WriteString(value);
447  }
448  }
449 
454  [global::__DynamicallyInvokable]
455  public virtual void WriteValue(bool value)
456  {
458  }
459 
464  public virtual void WriteValue(DateTime value)
465  {
467  }
468 
472  [global::__DynamicallyInvokable]
473  public virtual void WriteValue(DateTimeOffset value)
474  {
475  if (value.Offset != TimeSpan.Zero)
476  {
477  WriteValue(value.LocalDateTime);
478  }
479  else
480  {
481  WriteValue(value.UtcDateTime);
482  }
483  }
484 
489  [global::__DynamicallyInvokable]
490  public virtual void WriteValue(double value)
491  {
493  }
494 
499  [global::__DynamicallyInvokable]
500  public virtual void WriteValue(float value)
501  {
503  }
504 
509  [global::__DynamicallyInvokable]
510  public virtual void WriteValue(decimal value)
511  {
513  }
514 
519  [global::__DynamicallyInvokable]
520  public virtual void WriteValue(int value)
521  {
523  }
524 
529  [global::__DynamicallyInvokable]
530  public virtual void WriteValue(long value)
531  {
533  }
534 
543  [global::__DynamicallyInvokable]
544  public virtual void WriteAttributes(XmlReader reader, bool defattr)
545  {
546  if (reader == null)
547  {
548  throw new ArgumentNullException("reader");
549  }
550  if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.XmlDeclaration)
551  {
552  if (reader.MoveToFirstAttribute())
553  {
554  WriteAttributes(reader, defattr);
555  reader.MoveToElement();
556  }
557  return;
558  }
559  if (reader.NodeType != XmlNodeType.Attribute)
560  {
561  throw new XmlException("Xml_InvalidPosition", string.Empty);
562  }
563  do
564  {
565  if (!defattr && reader.IsDefaultInternal)
566  {
567  continue;
568  }
569  WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
570  while (reader.ReadAttributeValue())
571  {
572  if (reader.NodeType == XmlNodeType.EntityReference)
573  {
574  WriteEntityRef(reader.Name);
575  }
576  else
577  {
578  WriteString(reader.Value);
579  }
580  }
582  }
583  while (reader.MoveToNextAttribute());
584  }
585 
595  [global::__DynamicallyInvokable]
596  public virtual void WriteNode(XmlReader reader, bool defattr)
597  {
598  if (reader == null)
599  {
600  throw new ArgumentNullException("reader");
601  }
602  bool canReadValueChunk = reader.CanReadValueChunk;
603  int num = (reader.NodeType == XmlNodeType.None) ? (-1) : reader.Depth;
604  do
605  {
606  switch (reader.NodeType)
607  {
608  case XmlNodeType.Element:
609  WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
610  WriteAttributes(reader, defattr);
611  if (reader.IsEmptyElement)
612  {
613  WriteEndElement();
614  }
615  break;
616  case XmlNodeType.Text:
617  if (canReadValueChunk)
618  {
619  if (writeNodeBuffer == null)
620  {
621  writeNodeBuffer = new char[1024];
622  }
623  int count;
624  while ((count = reader.ReadValueChunk(writeNodeBuffer, 0, 1024)) > 0)
625  {
626  WriteChars(writeNodeBuffer, 0, count);
627  }
628  }
629  else
630  {
631  WriteString(reader.Value);
632  }
633  break;
634  case XmlNodeType.Whitespace:
635  case XmlNodeType.SignificantWhitespace:
636  WriteWhitespace(reader.Value);
637  break;
638  case XmlNodeType.CDATA:
639  WriteCData(reader.Value);
640  break;
641  case XmlNodeType.EntityReference:
642  WriteEntityRef(reader.Name);
643  break;
644  case XmlNodeType.ProcessingInstruction:
645  case XmlNodeType.XmlDeclaration:
646  WriteProcessingInstruction(reader.Name, reader.Value);
647  break;
648  case XmlNodeType.DocumentType:
649  WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
650  break;
651  case XmlNodeType.Comment:
652  WriteComment(reader.Value);
653  break;
654  case XmlNodeType.EndElement:
656  break;
657  }
658  }
659  while (reader.Read() && (num < reader.Depth || (num == reader.Depth && reader.NodeType == XmlNodeType.EndElement)));
660  }
661 
669  public virtual void WriteNode(XPathNavigator navigator, bool defattr)
670  {
671  if (navigator == null)
672  {
673  throw new ArgumentNullException("navigator");
674  }
675  int num = 0;
676  navigator = navigator.Clone();
677  while (true)
678  {
679  bool flag = false;
680  switch (navigator.NodeType)
681  {
682  case XPathNodeType.Element:
683  WriteStartElement(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI);
684  if (navigator.MoveToFirstAttribute())
685  {
686  do
687  {
688  IXmlSchemaInfo schemaInfo = navigator.SchemaInfo;
689  if (defattr || schemaInfo == null || !schemaInfo.IsDefault)
690  {
691  WriteStartAttribute(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI);
692  WriteString(navigator.Value);
694  }
695  }
696  while (navigator.MoveToNextAttribute());
697  navigator.MoveToParent();
698  }
699  if (navigator.MoveToFirstNamespace(XPathNamespaceScope.Local))
700  {
701  WriteLocalNamespaces(navigator);
702  navigator.MoveToParent();
703  }
704  flag = true;
705  break;
706  case XPathNodeType.Text:
707  WriteString(navigator.Value);
708  break;
709  case XPathNodeType.SignificantWhitespace:
710  case XPathNodeType.Whitespace:
711  WriteWhitespace(navigator.Value);
712  break;
713  case XPathNodeType.Root:
714  flag = true;
715  break;
716  case XPathNodeType.Comment:
717  WriteComment(navigator.Value);
718  break;
719  case XPathNodeType.ProcessingInstruction:
720  WriteProcessingInstruction(navigator.LocalName, navigator.Value);
721  break;
722  }
723  if (flag)
724  {
725  if (navigator.MoveToFirstChild())
726  {
727  num++;
728  continue;
729  }
730  if (navigator.NodeType == XPathNodeType.Element)
731  {
732  if (navigator.IsEmptyElement)
733  {
734  WriteEndElement();
735  }
736  else
737  {
739  }
740  }
741  }
742  while (true)
743  {
744  if (num == 0)
745  {
746  return;
747  }
748  if (navigator.MoveToNext())
749  {
750  break;
751  }
752  num--;
753  navigator.MoveToParent();
754  if (navigator.NodeType == XPathNodeType.Element)
755  {
757  }
758  }
759  }
760  }
761 
768  [global::__DynamicallyInvokable]
769  public void WriteElementString(string localName, string value)
770  {
771  WriteElementString(localName, null, value);
772  }
773 
781  [global::__DynamicallyInvokable]
782  public void WriteElementString(string localName, string ns, string value)
783  {
784  WriteStartElement(localName, ns);
785  if (value != null && value.Length != 0)
786  {
787  WriteString(value);
788  }
789  WriteEndElement();
790  }
791 
800  [global::__DynamicallyInvokable]
801  public void WriteElementString(string prefix, string localName, string ns, string value)
802  {
803  WriteStartElement(prefix, localName, ns);
804  if (value != null && value.Length != 0)
805  {
806  WriteString(value);
807  }
808  WriteEndElement();
809  }
810 
813  [global::__DynamicallyInvokable]
814  public void Dispose()
815  {
816  Dispose(disposing: true);
817  }
818 
823  [global::__DynamicallyInvokable]
824  protected virtual void Dispose(bool disposing)
825  {
826  if (disposing && WriteState != WriteState.Closed)
827  {
828  Close();
829  }
830  }
831 
832  private void WriteLocalNamespaces(XPathNavigator nsNav)
833  {
834  string localName = nsNav.LocalName;
835  string value = nsNav.Value;
836  if (nsNav.MoveToNextNamespace(XPathNamespaceScope.Local))
837  {
838  WriteLocalNamespaces(nsNav);
839  }
840  if (localName.Length == 0)
841  {
842  WriteAttributeString(string.Empty, "xmlns", "http://www.w3.org/2000/xmlns/", value);
843  }
844  else
845  {
846  WriteAttributeString("xmlns", localName, "http://www.w3.org/2000/xmlns/", value);
847  }
848  }
849 
854  public static XmlWriter Create(string outputFileName)
855  {
856  return Create(outputFileName, null);
857  }
858 
864  public static XmlWriter Create(string outputFileName, XmlWriterSettings settings)
865  {
866  if (settings == null)
867  {
868  settings = new XmlWriterSettings();
869  }
870  return settings.CreateWriter(outputFileName);
871  }
872 
877  [global::__DynamicallyInvokable]
878  public static XmlWriter Create(Stream output)
879  {
880  return Create(output, null);
881  }
882 
888  [global::__DynamicallyInvokable]
889  public static XmlWriter Create(Stream output, XmlWriterSettings settings)
890  {
891  if (settings == null)
892  {
893  settings = new XmlWriterSettings();
894  }
895  return settings.CreateWriter(output);
896  }
897 
902  [global::__DynamicallyInvokable]
903  public static XmlWriter Create(TextWriter output)
904  {
905  return Create(output, null);
906  }
907 
913  [global::__DynamicallyInvokable]
914  public static XmlWriter Create(TextWriter output, XmlWriterSettings settings)
915  {
916  if (settings == null)
917  {
918  settings = new XmlWriterSettings();
919  }
920  return settings.CreateWriter(output);
921  }
922 
927  [global::__DynamicallyInvokable]
928  public static XmlWriter Create(StringBuilder output)
929  {
930  return Create(output, null);
931  }
932 
938  [global::__DynamicallyInvokable]
939  public static XmlWriter Create(StringBuilder output, XmlWriterSettings settings)
940  {
941  if (settings == null)
942  {
943  settings = new XmlWriterSettings();
944  }
945  if (output == null)
946  {
947  throw new ArgumentNullException("output");
948  }
949  return settings.CreateWriter(new StringWriter(output, CultureInfo.InvariantCulture));
950  }
951 
956  [global::__DynamicallyInvokable]
957  public static XmlWriter Create(XmlWriter output)
958  {
959  return Create(output, null);
960  }
961 
967  [global::__DynamicallyInvokable]
968  public static XmlWriter Create(XmlWriter output, XmlWriterSettings settings)
969  {
970  if (settings == null)
971  {
972  settings = new XmlWriterSettings();
973  }
974  return settings.CreateWriter(output);
975  }
976 
981  [global::__DynamicallyInvokable]
982  public virtual Task WriteStartDocumentAsync()
983  {
984  throw new NotImplementedException();
985  }
986 
992  [global::__DynamicallyInvokable]
993  public virtual Task WriteStartDocumentAsync(bool standalone)
994  {
995  throw new NotImplementedException();
996  }
997 
1002  [global::__DynamicallyInvokable]
1003  public virtual Task WriteEndDocumentAsync()
1004  {
1005  throw new NotImplementedException();
1006  }
1007 
1016  [global::__DynamicallyInvokable]
1017  public virtual Task WriteDocTypeAsync(string name, string pubid, string sysid, string subset)
1018  {
1019  throw new NotImplementedException();
1020  }
1021 
1029  [global::__DynamicallyInvokable]
1030  public virtual Task WriteStartElementAsync(string prefix, string localName, string ns)
1031  {
1032  throw new NotImplementedException();
1033  }
1034 
1039  [global::__DynamicallyInvokable]
1040  public virtual Task WriteEndElementAsync()
1041  {
1042  throw new NotImplementedException();
1043  }
1044 
1049  [global::__DynamicallyInvokable]
1051  {
1052  throw new NotImplementedException();
1053  }
1054 
1063  [global::__DynamicallyInvokable]
1064  public Task WriteAttributeStringAsync(string prefix, string localName, string ns, string value)
1065  {
1066  Task task = WriteStartAttributeAsync(prefix, localName, ns);
1067  if (task.IsSuccess())
1068  {
1069  return WriteStringAsync(value).CallTaskFuncWhenFinish(WriteEndAttributeAsync);
1070  }
1071  return WriteAttributeStringAsyncHelper(task, value);
1072  }
1073 
1074  private async Task WriteAttributeStringAsyncHelper(Task task, string value)
1075  {
1076  await task.ConfigureAwait(continueOnCapturedContext: false);
1077  await WriteStringAsync(value).ConfigureAwait(continueOnCapturedContext: false);
1078  await WriteEndAttributeAsync().ConfigureAwait(continueOnCapturedContext: false);
1079  }
1080 
1088  [global::__DynamicallyInvokable]
1089  protected internal virtual Task WriteStartAttributeAsync(string prefix, string localName, string ns)
1090  {
1091  throw new NotImplementedException();
1092  }
1093 
1098  [global::__DynamicallyInvokable]
1099  protected internal virtual Task WriteEndAttributeAsync()
1100  {
1101  throw new NotImplementedException();
1102  }
1103 
1109  [global::__DynamicallyInvokable]
1110  public virtual Task WriteCDataAsync(string text)
1111  {
1112  throw new NotImplementedException();
1113  }
1114 
1120  [global::__DynamicallyInvokable]
1121  public virtual Task WriteCommentAsync(string text)
1122  {
1123  throw new NotImplementedException();
1124  }
1125 
1132  [global::__DynamicallyInvokable]
1133  public virtual Task WriteProcessingInstructionAsync(string name, string text)
1134  {
1135  throw new NotImplementedException();
1136  }
1137 
1143  [global::__DynamicallyInvokable]
1144  public virtual Task WriteEntityRefAsync(string name)
1145  {
1146  throw new NotImplementedException();
1147  }
1148 
1154  [global::__DynamicallyInvokable]
1155  public virtual Task WriteCharEntityAsync(char ch)
1156  {
1157  throw new NotImplementedException();
1158  }
1159 
1165  [global::__DynamicallyInvokable]
1166  public virtual Task WriteWhitespaceAsync(string ws)
1167  {
1168  throw new NotImplementedException();
1169  }
1170 
1176  [global::__DynamicallyInvokable]
1177  public virtual Task WriteStringAsync(string text)
1178  {
1179  throw new NotImplementedException();
1180  }
1181 
1188  [global::__DynamicallyInvokable]
1189  public virtual Task WriteSurrogateCharEntityAsync(char lowChar, char highChar)
1190  {
1191  throw new NotImplementedException();
1192  }
1193 
1201  [global::__DynamicallyInvokable]
1202  public virtual Task WriteCharsAsync(char[] buffer, int index, int count)
1203  {
1204  throw new NotImplementedException();
1205  }
1206 
1214  [global::__DynamicallyInvokable]
1215  public virtual Task WriteRawAsync(char[] buffer, int index, int count)
1216  {
1217  throw new NotImplementedException();
1218  }
1219 
1225  [global::__DynamicallyInvokable]
1226  public virtual Task WriteRawAsync(string data)
1227  {
1228  throw new NotImplementedException();
1229  }
1230 
1238  [global::__DynamicallyInvokable]
1239  public virtual Task WriteBase64Async(byte[] buffer, int index, int count)
1240  {
1241  throw new NotImplementedException();
1242  }
1243 
1251  [global::__DynamicallyInvokable]
1252  public virtual Task WriteBinHexAsync(byte[] buffer, int index, int count)
1253  {
1254  return BinHexEncoder.EncodeAsync(buffer, index, count, this);
1255  }
1256 
1261  [global::__DynamicallyInvokable]
1262  public virtual Task FlushAsync()
1263  {
1264  throw new NotImplementedException();
1265  }
1266 
1272  [global::__DynamicallyInvokable]
1273  public virtual Task WriteNmTokenAsync(string name)
1274  {
1275  if (name == null || name.Length == 0)
1276  {
1277  throw new ArgumentException(Res.GetString("Xml_EmptyName"));
1278  }
1279  return WriteStringAsync(XmlConvert.VerifyNMTOKEN(name, ExceptionType.ArgumentException));
1280  }
1281 
1287  [global::__DynamicallyInvokable]
1288  public virtual Task WriteNameAsync(string name)
1289  {
1290  return WriteStringAsync(XmlConvert.VerifyQName(name, ExceptionType.ArgumentException));
1291  }
1292 
1299  [global::__DynamicallyInvokable]
1300  public virtual async Task WriteQualifiedNameAsync(string localName, string ns)
1301  {
1302  if (ns != null && ns.Length > 0)
1303  {
1304  string text = LookupPrefix(ns);
1305  if (text == null)
1306  {
1307  throw new ArgumentException(Res.GetString("Xml_UndefNamespace", ns));
1308  }
1309  await WriteStringAsync(text).ConfigureAwait(continueOnCapturedContext: false);
1310  await WriteStringAsync(":").ConfigureAwait(continueOnCapturedContext: false);
1311  }
1312  await WriteStringAsync(localName).ConfigureAwait(continueOnCapturedContext: false);
1313  }
1314 
1322  [global::__DynamicallyInvokable]
1323  public virtual async Task WriteAttributesAsync(XmlReader reader, bool defattr)
1324  {
1325  if (reader == null)
1326  {
1327  throw new ArgumentNullException("reader");
1328  }
1329  if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.XmlDeclaration)
1330  {
1331  if (reader.MoveToFirstAttribute())
1332  {
1333  await WriteAttributesAsync(reader, defattr).ConfigureAwait(continueOnCapturedContext: false);
1334  reader.MoveToElement();
1335  }
1336  return;
1337  }
1338  if (reader.NodeType != XmlNodeType.Attribute)
1339  {
1340  throw new XmlException("Xml_InvalidPosition", string.Empty);
1341  }
1342  do
1343  {
1344  if (!defattr && reader.IsDefaultInternal)
1345  {
1346  continue;
1347  }
1348  await WriteStartAttributeAsync(reader.Prefix, reader.LocalName, reader.NamespaceURI).ConfigureAwait(continueOnCapturedContext: false);
1349  while (reader.ReadAttributeValue())
1350  {
1351  if (reader.NodeType == XmlNodeType.EntityReference)
1352  {
1353  await WriteEntityRefAsync(reader.Name).ConfigureAwait(continueOnCapturedContext: false);
1354  }
1355  else
1356  {
1357  await WriteStringAsync(reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1358  }
1359  }
1360  await WriteEndAttributeAsync().ConfigureAwait(continueOnCapturedContext: false);
1361  }
1362  while (reader.MoveToNextAttribute());
1363  }
1364 
1372  [global::__DynamicallyInvokable]
1373  public virtual Task WriteNodeAsync(XmlReader reader, bool defattr)
1374  {
1375  if (reader == null)
1376  {
1377  throw new ArgumentNullException("reader");
1378  }
1379  if (reader.Settings != null && reader.Settings.Async)
1380  {
1381  return WriteNodeAsync_CallAsyncReader(reader, defattr);
1382  }
1383  return WriteNodeAsync_CallSyncReader(reader, defattr);
1384  }
1385 
1386  internal async Task WriteNodeAsync_CallSyncReader(XmlReader reader, bool defattr)
1387  {
1388  bool canReadChunk = reader.CanReadValueChunk;
1389  int d = (reader.NodeType == XmlNodeType.None) ? (-1) : reader.Depth;
1390  do
1391  {
1392  switch (reader.NodeType)
1393  {
1394  case XmlNodeType.Element:
1395  await WriteStartElementAsync(reader.Prefix, reader.LocalName, reader.NamespaceURI).ConfigureAwait(continueOnCapturedContext: false);
1396  await WriteAttributesAsync(reader, defattr).ConfigureAwait(continueOnCapturedContext: false);
1397  if (reader.IsEmptyElement)
1398  {
1399  await WriteEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1400  }
1401  break;
1402  case XmlNodeType.Text:
1403  if (canReadChunk)
1404  {
1405  if (writeNodeBuffer == null)
1406  {
1407  writeNodeBuffer = new char[1024];
1408  }
1409  int read;
1410  while ((read = reader.ReadValueChunk(writeNodeBuffer, 0, 1024)) > 0)
1411  {
1412  await WriteCharsAsync(writeNodeBuffer, 0, read).ConfigureAwait(continueOnCapturedContext: false);
1413  }
1414  }
1415  else
1416  {
1417  await WriteStringAsync(reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1418  }
1419  break;
1420  case XmlNodeType.Whitespace:
1421  case XmlNodeType.SignificantWhitespace:
1422  await WriteWhitespaceAsync(reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1423  break;
1424  case XmlNodeType.CDATA:
1425  await WriteCDataAsync(reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1426  break;
1427  case XmlNodeType.EntityReference:
1428  await WriteEntityRefAsync(reader.Name).ConfigureAwait(continueOnCapturedContext: false);
1429  break;
1430  case XmlNodeType.ProcessingInstruction:
1431  case XmlNodeType.XmlDeclaration:
1432  await WriteProcessingInstructionAsync(reader.Name, reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1433  break;
1434  case XmlNodeType.DocumentType:
1435  await WriteDocTypeAsync(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1436  break;
1437  case XmlNodeType.Comment:
1438  await WriteCommentAsync(reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1439  break;
1440  case XmlNodeType.EndElement:
1441  await WriteFullEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1442  break;
1443  }
1444  }
1445  while (reader.Read() && (d < reader.Depth || (d == reader.Depth && reader.NodeType == XmlNodeType.EndElement)));
1446  }
1447 
1448  internal async Task WriteNodeAsync_CallAsyncReader(XmlReader reader, bool defattr)
1449  {
1450  bool canReadChunk = reader.CanReadValueChunk;
1451  int d = (reader.NodeType == XmlNodeType.None) ? (-1) : reader.Depth;
1452  do
1453  {
1454  switch (reader.NodeType)
1455  {
1456  case XmlNodeType.Element:
1457  await WriteStartElementAsync(reader.Prefix, reader.LocalName, reader.NamespaceURI).ConfigureAwait(continueOnCapturedContext: false);
1458  await WriteAttributesAsync(reader, defattr).ConfigureAwait(continueOnCapturedContext: false);
1459  if (reader.IsEmptyElement)
1460  {
1461  await WriteEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1462  }
1463  break;
1464  case XmlNodeType.Text:
1465  if (canReadChunk)
1466  {
1467  if (writeNodeBuffer == null)
1468  {
1469  writeNodeBuffer = new char[1024];
1470  }
1471  int read;
1472  while ((read = await reader.ReadValueChunkAsync(writeNodeBuffer, 0, 1024).ConfigureAwait(continueOnCapturedContext: false)) > 0)
1473  {
1474  await WriteCharsAsync(writeNodeBuffer, 0, read).ConfigureAwait(continueOnCapturedContext: false);
1475  }
1476  }
1477  else
1478  {
1479  await WriteStringAsync(await reader.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false)).ConfigureAwait(continueOnCapturedContext: false);
1480  }
1481  break;
1482  case XmlNodeType.Whitespace:
1483  case XmlNodeType.SignificantWhitespace:
1484  await WriteWhitespaceAsync(await reader.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false)).ConfigureAwait(continueOnCapturedContext: false);
1485  break;
1486  case XmlNodeType.CDATA:
1487  await WriteCDataAsync(reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1488  break;
1489  case XmlNodeType.EntityReference:
1490  await WriteEntityRefAsync(reader.Name).ConfigureAwait(continueOnCapturedContext: false);
1491  break;
1492  case XmlNodeType.ProcessingInstruction:
1493  case XmlNodeType.XmlDeclaration:
1494  await WriteProcessingInstructionAsync(reader.Name, reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1495  break;
1496  case XmlNodeType.DocumentType:
1497  await WriteDocTypeAsync(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1498  break;
1499  case XmlNodeType.Comment:
1500  await WriteCommentAsync(reader.Value).ConfigureAwait(continueOnCapturedContext: false);
1501  break;
1502  case XmlNodeType.EndElement:
1503  await WriteFullEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1504  break;
1505  }
1506  }
1507  while (await reader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false) && (d < reader.Depth || (d == reader.Depth && reader.NodeType == XmlNodeType.EndElement)));
1508  }
1509 
1517  public virtual async Task WriteNodeAsync(XPathNavigator navigator, bool defattr)
1518  {
1519  if (navigator == null)
1520  {
1521  throw new ArgumentNullException("navigator");
1522  }
1523  int iLevel = 0;
1524  navigator = navigator.Clone();
1525  while (true)
1526  {
1527  bool mayHaveChildren = false;
1528  switch (navigator.NodeType)
1529  {
1530  case XPathNodeType.Element:
1531  await WriteStartElementAsync(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI).ConfigureAwait(continueOnCapturedContext: false);
1532  if (navigator.MoveToFirstAttribute())
1533  {
1534  do
1535  {
1536  IXmlSchemaInfo schemaInfo = navigator.SchemaInfo;
1537  if (defattr || schemaInfo == null || !schemaInfo.IsDefault)
1538  {
1539  await WriteStartAttributeAsync(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI).ConfigureAwait(continueOnCapturedContext: false);
1540  await WriteStringAsync(navigator.Value).ConfigureAwait(continueOnCapturedContext: false);
1541  await WriteEndAttributeAsync().ConfigureAwait(continueOnCapturedContext: false);
1542  }
1543  }
1544  while (navigator.MoveToNextAttribute());
1545  navigator.MoveToParent();
1546  }
1547  if (navigator.MoveToFirstNamespace(XPathNamespaceScope.Local))
1548  {
1549  await WriteLocalNamespacesAsync(navigator).ConfigureAwait(continueOnCapturedContext: false);
1550  navigator.MoveToParent();
1551  }
1552  mayHaveChildren = true;
1553  break;
1554  case XPathNodeType.Text:
1555  await WriteStringAsync(navigator.Value).ConfigureAwait(continueOnCapturedContext: false);
1556  break;
1557  case XPathNodeType.SignificantWhitespace:
1558  case XPathNodeType.Whitespace:
1559  await WriteWhitespaceAsync(navigator.Value).ConfigureAwait(continueOnCapturedContext: false);
1560  break;
1561  case XPathNodeType.Root:
1562  mayHaveChildren = true;
1563  break;
1564  case XPathNodeType.Comment:
1565  await WriteCommentAsync(navigator.Value).ConfigureAwait(continueOnCapturedContext: false);
1566  break;
1567  case XPathNodeType.ProcessingInstruction:
1568  await WriteProcessingInstructionAsync(navigator.LocalName, navigator.Value).ConfigureAwait(continueOnCapturedContext: false);
1569  break;
1570  }
1571  if (mayHaveChildren)
1572  {
1573  if (navigator.MoveToFirstChild())
1574  {
1575  iLevel++;
1576  continue;
1577  }
1578  if (navigator.NodeType == XPathNodeType.Element)
1579  {
1580  if (!navigator.IsEmptyElement)
1581  {
1582  await WriteFullEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1583  }
1584  else
1585  {
1586  await WriteEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1587  }
1588  }
1589  }
1590  while (true)
1591  {
1592  if (iLevel == 0)
1593  {
1594  return;
1595  }
1596  if (navigator.MoveToNext())
1597  {
1598  break;
1599  }
1600  iLevel--;
1601  navigator.MoveToParent();
1602  if (navigator.NodeType == XPathNodeType.Element)
1603  {
1604  await WriteFullEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1605  }
1606  }
1607  }
1608  }
1609 
1618  [global::__DynamicallyInvokable]
1619  public async Task WriteElementStringAsync(string prefix, string localName, string ns, string value)
1620  {
1621  await WriteStartElementAsync(prefix, localName, ns).ConfigureAwait(continueOnCapturedContext: false);
1622  if (value != null && value.Length != 0)
1623  {
1624  await WriteStringAsync(value).ConfigureAwait(continueOnCapturedContext: false);
1625  }
1626  await WriteEndElementAsync().ConfigureAwait(continueOnCapturedContext: false);
1627  }
1628 
1629  private async Task WriteLocalNamespacesAsync(XPathNavigator nsNav)
1630  {
1631  string prefix = nsNav.LocalName;
1632  string ns = nsNav.Value;
1633  if (nsNav.MoveToNextNamespace(XPathNamespaceScope.Local))
1634  {
1635  await WriteLocalNamespacesAsync(nsNav).ConfigureAwait(continueOnCapturedContext: false);
1636  }
1637  if (prefix.Length == 0)
1638  {
1639  await WriteAttributeStringAsync(string.Empty, "xmlns", "http://www.w3.org/2000/xmlns/", ns).ConfigureAwait(continueOnCapturedContext: false);
1640  }
1641  else
1642  {
1643  await WriteAttributeStringAsync("xmlns", prefix, "http://www.w3.org/2000/xmlns/", ns).ConfigureAwait(continueOnCapturedContext: false);
1644  }
1645  }
1646 
1648  [global::__DynamicallyInvokable]
1649  protected XmlWriter()
1650  {
1651  }
1652  }
1653 }
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Definition: CultureInfo.cs:263
WriteState
Specifies the state of the T:System.Xml.XmlWriter.
Definition: WriteState.cs:5
virtual void WriteValue(DateTime value)
Writes a T:System.DateTime value.
Definition: XmlWriter.cs:464
bool Async
Gets or sets whether asynchronous T:System.Xml.XmlReader methods can be used on a particular T:System...
abstract bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the next namespace...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
XPathNamespaceScope
Defines the namespace scope.
abstract string NamespaceURI
When overridden in a derived class, gets the namespace URI of the current node.
static XmlWriter Create(XmlWriter output, XmlWriterSettings settings)
Creates a new T:System.Xml.XmlWriter instance using the specified T:System.Xml.XmlWriter and T:System...
Definition: XmlWriter.cs:968
static XmlWriter Create(Stream output)
Creates a new T:System.Xml.XmlWriter instance using the specified stream.
Definition: XmlWriter.cs:878
XmlWriter()
Initializes a new instance of the T:System.Xml.XmlWriter class.
Definition: XmlWriter.cs:1649
Defines the post-schema-validation infoset of a validated XML node.
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
abstract void WriteBase64(byte[] buffer, int index, int count)
When overridden in a derived class, encodes the specified binary bytes as Base64 and writes out the r...
void Dispose()
Releases all resources used by the current instance of the T:System.Xml.XmlWriter class.
Definition: XmlWriter.cs:814
abstract void WriteChars(char[] buffer, int index, int count)
When overridden in a derived class, writes text one buffer at a time.
abstract bool MoveToElement()
When overridden in a derived class, moves to the element that contains the current attribute node.
virtual void WriteBinHex(byte[] buffer, int index, int count)
When overridden in a derived class, encodes the specified binary bytes as BinHex and writes out the r...
Definition: XmlWriter.cs:345
void WriteAttributeString(string localName, string value)
When overridden in a derived class, writes out the attribute with the specified local name and value.
Definition: XmlWriter.cs:169
abstract string LocalName
When overridden in a derived class, gets the local name of the current node.
Definition: XmlReader.cs:133
static XmlWriter Create(string outputFileName)
Creates a new T:System.Xml.XmlWriter instance using the specified filename.
Definition: XmlWriter.cs:854
abstract void WriteStartDocument()
When overridden in a derived class, writes the XML declaration with the version "1....
virtual void WriteValue(bool value)
Writes a T:System.Boolean value.
Definition: XmlWriter.cs:455
Implements a T:System.IO.TextWriter for writing information to a string. The information is stored in...
Definition: StringWriter.cs:13
static XmlWriter Create(StringBuilder output, XmlWriterSettings settings)
Creates a new T:System.Xml.XmlWriter instance using the T:System.Text.StringBuilder and T:System....
Definition: XmlWriter.cs:939
abstract bool MoveToNext()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the next sibling n...
virtual Task WriteFullEndElementAsync()
Asynchronously closes one element and pops the corresponding namespace scope.
Definition: XmlWriter.cs:1050
virtual Task WriteProcessingInstructionAsync(string name, string text)
Asynchronously writes out a processing instruction with a space between the name and text as follows:...
Definition: XmlWriter.cs:1133
void WriteStartElement(string localName)
When overridden in a derived class, writes out a start tag with the specified local name.
Definition: XmlWriter.cs:131
void WriteElementString(string localName, string ns, string value)
Writes an element with the specified local name, namespace URI, and value.
Definition: XmlWriter.cs:782
static XmlWriter Create(XmlWriter output)
Creates a new T:System.Xml.XmlWriter instance using the specified T:System.Xml.XmlWriter object.
Definition: XmlWriter.cs:957
abstract bool MoveToNextAttribute()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the next attribute...
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Definition: IDisposable.cs:8
virtual void WriteValue(DateTimeOffset value)
Writes a T:System.DateTimeOffset value.
Definition: XmlWriter.cs:473
Definition: __Canon.cs:3
virtual void WriteValue(decimal value)
Writes a T:System.Decimal value.
Definition: XmlWriter.cs:510
virtual void WriteValue(long value)
Writes a T:System.Int64 value.
Definition: XmlWriter.cs:530
virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.Xml.XmlWriter and optionally releases the manag...
Definition: XmlWriter.cs:824
abstract void WriteEndAttribute()
When overridden in a derived class, closes the previous M:System.Xml.XmlWriter.WriteStartAttribute(Sy...
static string ToString(bool value)
Converts the T:System.Boolean to a T:System.String.
Definition: XmlConvert.cs:601
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 void WriteQualifiedName(string localName, string ns)
When overridden in a derived class, writes out the namespace-qualified name. This method looks up the...
Definition: XmlWriter.cs:405
virtual void WriteNode(XPathNavigator navigator, bool defattr)
Copies everything from the T:System.Xml.XPath.XPathNavigator object to the writer....
Definition: XmlWriter.cs:669
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
XmlNodeType
Specifies the type of node.
Definition: XmlNodeType.cs:5
virtual Task WriteCommentAsync(string text)
Asynchronously writes out a comment <!–...–> containing the specified text.
Definition: XmlWriter.cs:1121
abstract void WriteString(string text)
When overridden in a derived class, writes the given text content.
void WriteElementString(string prefix, string localName, string ns, string value)
Writes an element with the specified prefix, local name, namespace URI, and value.
Definition: XmlWriter.cs:801
virtual string XmlLang
When overridden in a derived class, gets the current xml:lang scope.
Definition: XmlWriter.cs:65
abstract void WriteEndDocument()
When overridden in a derived class, closes any open elements or attributes and puts the writer back i...
virtual Task FlushAsync()
Asynchronously flushes whatever is in the buffer to the underlying streams and also flushes the under...
Definition: XmlWriter.cs:1262
virtual Task WriteStartDocumentAsync(bool standalone)
Asynchronously writes the XML declaration with the version "1.0" and the standalone attribute.
Definition: XmlWriter.cs:993
virtual async Task WriteQualifiedNameAsync(string localName, string ns)
Asynchronously writes out the namespace-qualified name. This method looks up the prefix that is in sc...
Definition: XmlWriter.cs:1300
XPathNodeType
Defines the XPath node types that can be returned from the T:System.Xml.XPath.XPathNavigator class.
Definition: XPathNodeType.cs:4
static XmlWriter Create(StringBuilder output)
Creates a new T:System.Xml.XmlWriter instance using the specified T:System.Text.StringBuilder.
Definition: XmlWriter.cs:928
void WriteAttributeString(string prefix, string localName, string ns, string value)
When overridden in a derived class, writes out the attribute with the specified prefix,...
Definition: XmlWriter.cs:186
abstract string LookupPrefix(string ns)
When overridden in a derived class, returns the closest prefix defined in the current namespace scope...
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
virtual void WriteNmToken(string name)
When overridden in a derived class, writes out the specified name, ensuring it is a valid NmToken acc...
Definition: XmlWriter.cs:377
abstract XPathNodeType NodeType
When overridden in a derived class, gets the T:System.Xml.XPath.XPathNodeType of the current node.
Represents a reader that provides fast, noncached, forward-only access to XML data....
Definition: XmlReader.cs:15
virtual Task WriteRawAsync(char[] buffer, int index, int count)
Asynchronously writes raw markup manually from a character buffer.
Definition: XmlWriter.cs:1215
abstract void Flush()
When overridden in a derived class, flushes whatever is in the buffer to the underlying streams and a...
abstract bool MoveToFirstAttribute()
When overridden in a derived class, moves to the first attribute.
virtual string Name
When overridden in a derived class, gets the qualified name of the current node.
Definition: XmlReader.cs:116
abstract string Prefix
When overridden in a derived class, gets the namespace prefix associated with the current node.
void WriteStartAttribute(string localName)
Writes the start of an attribute with the specified local name.
Definition: XmlWriter.cs:219
virtual Task WriteCharEntityAsync(char ch)
Asynchronously forces the generation of a character entity for the specified Unicode character value.
Definition: XmlWriter.cs:1155
virtual void WriteValue(string value)
Writes a T:System.String value.
Definition: XmlWriter.cs:442
virtual Task WriteStartElementAsync(string prefix, string localName, string ns)
Asynchronously writes the specified start tag and associates it with the given namespace and prefix.
Definition: XmlWriter.cs:1030
virtual Task WriteCDataAsync(string text)
Asynchronously writes out a <![CDATA[...]]> block containing the specified text.
Definition: XmlWriter.cs:1110
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
abstract bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the first namespac...
abstract void WriteCharEntity(char ch)
When overridden in a derived class, forces the generation of a character entity for the specified Uni...
Represents a writer that can write a sequential series of characters. This class is abstract.
Definition: TextWriter.cs:15
virtual Task WriteRawAsync(string data)
Asynchronously writes raw markup manually from a string.
Definition: XmlWriter.cs:1226
abstract bool IsEmptyElement
When overridden in a derived class, gets a value indicating whether the current node is an empty elem...
virtual Task WriteStringAsync(string text)
Asynchronously writes the given text content.
Definition: XmlWriter.cs:1177
virtual XmlReaderSettings Settings
Gets the T:System.Xml.XmlReaderSettings object used to create this T:System.Xml.XmlReader instance.
Definition: XmlReader.cs:81
Task WriteAttributeStringAsync(string prefix, string localName, string ns, string value)
Asynchronously writes out the attribute with the specified prefix, local name, namespace URI,...
Definition: XmlWriter.cs:1064
abstract void WriteCData(string text)
When overridden in a derived class, writes out a <![CDATA[...]]> block containing the specified text.
virtual Task WriteBase64Async(byte[] buffer, int index, int count)
Asynchronously encodes the specified binary bytes as Base64 and writes out the resulting text.
Definition: XmlWriter.cs:1239
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 Task WriteNameAsync(string name)
Asynchronously writes out the specified name, ensuring it is a valid name according to the W3C XML 1....
Definition: XmlWriter.cs:1288
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.
static readonly TimeSpan Zero
Represents the zero T:System.TimeSpan value. This field is read-only.
Definition: TimeSpan.cs:64
void WriteAttributeString(string localName, string ns, string value)
When overridden in a derived class, writes an attribute with the specified local name,...
Definition: XmlWriter.cs:155
virtual Task WriteWhitespaceAsync(string ws)
Asynchronously writes out the given white space.
Definition: XmlWriter.cs:1166
virtual bool CanReadValueChunk
Gets a value indicating whether the T:System.Xml.XmlReader implements the M:System....
Definition: XmlReader.cs:412
abstract bool MoveToNextAttribute()
When overridden in a derived class, moves to the next attribute.
virtual void WriteValue(object value)
Writes the object value.
Definition: XmlWriter.cs:428
Specifies a set of features to support on the T:System.Xml.XmlWriter object created by the Overload:S...
static string VerifyNMTOKEN(string name)
Verifies that the string is a valid NMTOKEN according to the W3C XML Schema Part2: Datatypes recommen...
Definition: XmlConvert.cs:431
static XmlWriter Create(Stream output, XmlWriterSettings settings)
Creates a new T:System.Xml.XmlWriter instance using the stream and T:System.Xml.XmlWriterSettings obj...
Definition: XmlWriter.cs:889
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
virtual internal Task WriteEndAttributeAsync()
Asynchronously closes the previous M:System.Xml.XmlWriter.WriteStartAttribute(System....
Definition: XmlWriter.cs:1099
abstract void WriteSurrogateCharEntity(char lowChar, char highChar)
When overridden in a derived class, generates and writes the surrogate character entity for the surro...
Returns detailed information about the last exception.
Definition: XmlException.cs:12
virtual Task WriteBinHexAsync(byte[] buffer, int index, int count)
Asynchronously encodes the specified binary bytes as BinHex and writes out the resulting text.
Definition: XmlWriter.cs:1252
abstract string GetAttribute(string name)
When overridden in a derived class, gets the value of the attribute with the specified P:System....
abstract void WriteEntityRef(string name)
When overridden in a derived class, writes out an entity reference as &name;.
virtual IXmlSchemaInfo SchemaInfo
Gets the schema information that has been assigned to the current node as a result of schema validati...
abstract void WriteRaw(char[] buffer, int index, int count)
When overridden in a derived class, writes raw markup manually from a character buffer.
The exception that is thrown when one of the arguments provided to a method is not valid.
abstract bool Read()
When overridden in a derived class, reads the next node from the stream.
virtual Task WriteEndElementAsync()
Asynchronously closes one element and pops the corresponding namespace scope.
Definition: XmlWriter.cs:1040
virtual void Close()
When overridden in a derived class, closes this stream and the underlying stream.
Definition: XmlWriter.cs:353
abstract bool MoveToFirstChild()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the first child no...
abstract string Prefix
When overridden in a derived class, gets the namespace prefix associated with the current node.
Definition: XmlReader.cs:153
virtual XmlWriterSettings Settings
Gets the T:System.Xml.XmlWriterSettings object used to create this T:System.Xml.XmlWriter instance.
Definition: XmlWriter.cs:23
virtual internal Task WriteStartAttributeAsync(string prefix, string localName, string ns)
Asynchronously writes the start of an attribute with the specified prefix, local name,...
Definition: XmlWriter.cs:1089
virtual Task WriteEntityRefAsync(string name)
Asynchronously writes out an entity reference as &name;.
Definition: XmlWriter.cs:1144
virtual Task WriteEndDocumentAsync()
Asynchronously closes any open elements or attributes and puts the writer back in the Start state.
Definition: XmlWriter.cs:1003
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 void WriteValue(float value)
Writes a single-precision floating-point number.
Definition: XmlWriter.cs:500
virtual Task WriteNodeAsync(XmlReader reader, bool defattr)
Asynchronously copies everything from the reader to the writer and moves the reader to the start of t...
Definition: XmlWriter.cs:1373
abstract bool MoveToParent()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the parent node of...
virtual async Task WriteAttributesAsync(XmlReader reader, bool defattr)
Asynchronously writes out all the attributes found at the current position in the T:System....
Definition: XmlWriter.cs:1323
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
Represents a time interval.To browse the .NET Framework source code for this type,...
Definition: TimeSpan.cs:12
virtual Task WriteStartDocumentAsync()
Asynchronously writes the XML declaration with the version "1.0".
Definition: XmlWriter.cs:982
Provides a cursor model for navigating and editing XML data.
static XmlWriter Create(TextWriter output, XmlWriterSettings settings)
Creates a new T:System.Xml.XmlWriter instance using the T:System.IO.TextWriter and T:System....
Definition: XmlWriter.cs:914
async Task WriteElementStringAsync(string prefix, string localName, string ns, string value)
Asynchronously writes an element with the specified prefix, local name, namespace URI,...
Definition: XmlWriter.cs:1619
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
abstract bool MoveToFirstAttribute()
When overridden in a derived class, moves the T:System.Xml.XPath.XPathNavigator to the first attribut...
abstract string Value
When overridden in a derived class, gets the string value of the item.
Definition: XPathItem.cs:26
abstract void WriteProcessingInstruction(string name, string text)
When overridden in a derived class, writes out a processing instruction with a space between the name...
XmlSpace
Specifies the current xml:space scope.
Definition: XmlSpace.cs:5
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
virtual Task WriteDocTypeAsync(string name, string pubid, string sysid, string subset)
Asynchronously writes the DOCTYPE declaration with the specified name and optional attributes.
Definition: XmlWriter.cs:1017
abstract string Value
When overridden in a derived class, gets the text value of the current node.
Definition: XmlReader.cs:195
abstract bool ReadAttributeValue()
When overridden in a derived class, parses the attribute value into one or more Text,...
abstract string LocalName
When overridden in a derived class, gets the P:System.Xml.XPath.XPathNavigator.Name of the current no...
static XmlWriter Create(TextWriter output)
Creates a new T:System.Xml.XmlWriter instance using the specified T:System.IO.TextWriter.
Definition: XmlWriter.cs:903
virtual Task WriteNmTokenAsync(string name)
Asynchronously writes out the specified name, ensuring it is a valid NmToken according to the W3C XML...
Definition: XmlWriter.cs:1273
virtual async Task WriteNodeAsync(XPathNavigator navigator, bool defattr)
Asynchronously copies everything from the T:System.Xml.XPath.XPathNavigator object to the writer....
Definition: XmlWriter.cs:1517
The exception that is thrown when a requested method or operation is not implemented.
XmlDateTimeSerializationMode
Specifies how to treat the time value when converting between string and T:System....
void WriteElementString(string localName, string value)
Writes an element with the specified local name and value.
Definition: XmlWriter.cs:769
virtual Task WriteSurrogateCharEntityAsync(char lowChar, char highChar)
Asynchronously generates and writes the surrogate character entity for the surrogate character pair.
Definition: XmlWriter.cs:1189
static XmlWriter Create(string outputFileName, XmlWriterSettings settings)
Creates a new T:System.Xml.XmlWriter instance using the filename and T:System.Xml....
Definition: XmlWriter.cs:864
virtual void WriteValue(double value)
Writes a T:System.Double value.
Definition: XmlWriter.cs:490
virtual void WriteName(string name)
When overridden in a derived class, writes out the specified name, ensuring it is a valid name accord...
Definition: XmlWriter.cs:392
virtual Task WriteCharsAsync(char[] buffer, int index, int count)
Asynchronously writes text one buffer at a time.
Definition: XmlWriter.cs:1202
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...
virtual void WriteValue(int value)
Writes a T:System.Int32 value.
Definition: XmlWriter.cs:520
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
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....
Definition: Stream.cs:16