mscorlib(4.0.0.0) API with additions
TextWriter.cs
5 using System.Text;
6 using System.Threading;
8 
9 namespace System.IO
10 {
12  [Serializable]
13  [ComVisible(true)]
14  [__DynamicallyInvokable]
15  public abstract class TextWriter : MarshalByRefObject, IDisposable
16  {
17  [Serializable]
18  private sealed class NullTextWriter : TextWriter
19  {
20  public override Encoding Encoding => Encoding.Default;
21 
22  internal NullTextWriter()
24  {
25  }
26 
27  public override void Write(char[] buffer, int index, int count)
28  {
29  }
30 
31  public override void Write(string value)
32  {
33  }
34 
35  public override void WriteLine()
36  {
37  }
38 
39  public override void WriteLine(string value)
40  {
41  }
42 
43  public override void WriteLine(object value)
44  {
45  }
46  }
47 
48  [Serializable]
49  internal sealed class SyncTextWriter : TextWriter, IDisposable
50  {
51  private TextWriter _out;
52 
53  public override Encoding Encoding => _out.Encoding;
54 
55  public override IFormatProvider FormatProvider => _out.FormatProvider;
56 
57  public override string NewLine
58  {
59  [MethodImpl(MethodImplOptions.Synchronized)]
60  get
61  {
62  return _out.NewLine;
63  }
64  [MethodImpl(MethodImplOptions.Synchronized)]
65  set
66  {
67  _out.NewLine = value;
68  }
69  }
70 
71  internal SyncTextWriter(TextWriter t)
72  : base(t.FormatProvider)
73  {
74  _out = t;
75  }
76 
77  [MethodImpl(MethodImplOptions.Synchronized)]
78  public override void Close()
79  {
80  _out.Close();
81  }
82 
83  [MethodImpl(MethodImplOptions.Synchronized)]
84  protected override void Dispose(bool disposing)
85  {
86  if (disposing)
87  {
88  ((IDisposable)_out).Dispose();
89  }
90  }
91 
92  [MethodImpl(MethodImplOptions.Synchronized)]
93  public override void Flush()
94  {
95  _out.Flush();
96  }
97 
98  [MethodImpl(MethodImplOptions.Synchronized)]
99  public override void Write(char value)
100  {
101  _out.Write(value);
102  }
103 
104  [MethodImpl(MethodImplOptions.Synchronized)]
105  public override void Write(char[] buffer)
106  {
107  _out.Write(buffer);
108  }
109 
110  [MethodImpl(MethodImplOptions.Synchronized)]
111  public override void Write(char[] buffer, int index, int count)
112  {
113  _out.Write(buffer, index, count);
114  }
115 
116  [MethodImpl(MethodImplOptions.Synchronized)]
117  public override void Write(bool value)
118  {
119  _out.Write(value);
120  }
121 
122  [MethodImpl(MethodImplOptions.Synchronized)]
123  public override void Write(int value)
124  {
125  _out.Write(value);
126  }
127 
128  [MethodImpl(MethodImplOptions.Synchronized)]
129  public override void Write(uint value)
130  {
131  _out.Write(value);
132  }
133 
134  [MethodImpl(MethodImplOptions.Synchronized)]
135  public override void Write(long value)
136  {
137  _out.Write(value);
138  }
139 
140  [MethodImpl(MethodImplOptions.Synchronized)]
141  public override void Write(ulong value)
142  {
143  _out.Write(value);
144  }
145 
146  [MethodImpl(MethodImplOptions.Synchronized)]
147  public override void Write(float value)
148  {
149  _out.Write(value);
150  }
151 
152  [MethodImpl(MethodImplOptions.Synchronized)]
153  public override void Write(double value)
154  {
155  _out.Write(value);
156  }
157 
158  [MethodImpl(MethodImplOptions.Synchronized)]
159  public override void Write(decimal value)
160  {
161  _out.Write(value);
162  }
163 
164  [MethodImpl(MethodImplOptions.Synchronized)]
165  public override void Write(string value)
166  {
167  _out.Write(value);
168  }
169 
170  [MethodImpl(MethodImplOptions.Synchronized)]
171  public override void Write(object value)
172  {
173  _out.Write(value);
174  }
175 
176  [MethodImpl(MethodImplOptions.Synchronized)]
177  public override void Write(string format, object arg0)
178  {
179  _out.Write(format, arg0);
180  }
181 
182  [MethodImpl(MethodImplOptions.Synchronized)]
183  public override void Write(string format, object arg0, object arg1)
184  {
185  _out.Write(format, arg0, arg1);
186  }
187 
188  [MethodImpl(MethodImplOptions.Synchronized)]
189  public override void Write(string format, object arg0, object arg1, object arg2)
190  {
191  _out.Write(format, arg0, arg1, arg2);
192  }
193 
194  [MethodImpl(MethodImplOptions.Synchronized)]
195  public override void Write(string format, params object[] arg)
196  {
197  _out.Write(format, arg);
198  }
199 
200  [MethodImpl(MethodImplOptions.Synchronized)]
201  public override void WriteLine()
202  {
203  _out.WriteLine();
204  }
205 
206  [MethodImpl(MethodImplOptions.Synchronized)]
207  public override void WriteLine(char value)
208  {
209  _out.WriteLine(value);
210  }
211 
212  [MethodImpl(MethodImplOptions.Synchronized)]
213  public override void WriteLine(decimal value)
214  {
215  _out.WriteLine(value);
216  }
217 
218  [MethodImpl(MethodImplOptions.Synchronized)]
219  public override void WriteLine(char[] buffer)
220  {
221  _out.WriteLine(buffer);
222  }
223 
224  [MethodImpl(MethodImplOptions.Synchronized)]
225  public override void WriteLine(char[] buffer, int index, int count)
226  {
227  _out.WriteLine(buffer, index, count);
228  }
229 
230  [MethodImpl(MethodImplOptions.Synchronized)]
231  public override void WriteLine(bool value)
232  {
233  _out.WriteLine(value);
234  }
235 
236  [MethodImpl(MethodImplOptions.Synchronized)]
237  public override void WriteLine(int value)
238  {
239  _out.WriteLine(value);
240  }
241 
242  [MethodImpl(MethodImplOptions.Synchronized)]
243  public override void WriteLine(uint value)
244  {
245  _out.WriteLine(value);
246  }
247 
248  [MethodImpl(MethodImplOptions.Synchronized)]
249  public override void WriteLine(long value)
250  {
251  _out.WriteLine(value);
252  }
253 
254  [MethodImpl(MethodImplOptions.Synchronized)]
255  public override void WriteLine(ulong value)
256  {
257  _out.WriteLine(value);
258  }
259 
260  [MethodImpl(MethodImplOptions.Synchronized)]
261  public override void WriteLine(float value)
262  {
263  _out.WriteLine(value);
264  }
265 
266  [MethodImpl(MethodImplOptions.Synchronized)]
267  public override void WriteLine(double value)
268  {
269  _out.WriteLine(value);
270  }
271 
272  [MethodImpl(MethodImplOptions.Synchronized)]
273  public override void WriteLine(string value)
274  {
275  _out.WriteLine(value);
276  }
277 
278  [MethodImpl(MethodImplOptions.Synchronized)]
279  public override void WriteLine(object value)
280  {
281  _out.WriteLine(value);
282  }
283 
284  [MethodImpl(MethodImplOptions.Synchronized)]
285  public override void WriteLine(string format, object arg0)
286  {
287  _out.WriteLine(format, arg0);
288  }
289 
290  [MethodImpl(MethodImplOptions.Synchronized)]
291  public override void WriteLine(string format, object arg0, object arg1)
292  {
293  _out.WriteLine(format, arg0, arg1);
294  }
295 
296  [MethodImpl(MethodImplOptions.Synchronized)]
297  public override void WriteLine(string format, object arg0, object arg1, object arg2)
298  {
299  _out.WriteLine(format, arg0, arg1, arg2);
300  }
301 
302  [MethodImpl(MethodImplOptions.Synchronized)]
303  public override void WriteLine(string format, params object[] arg)
304  {
305  _out.WriteLine(format, arg);
306  }
307 
308  [MethodImpl(MethodImplOptions.Synchronized)]
309  [ComVisible(false)]
310  public override Task WriteAsync(char value)
311  {
312  Write(value);
313  return Task.CompletedTask;
314  }
315 
316  [MethodImpl(MethodImplOptions.Synchronized)]
317  [ComVisible(false)]
318  public override Task WriteAsync(string value)
319  {
320  Write(value);
321  return Task.CompletedTask;
322  }
323 
324  [MethodImpl(MethodImplOptions.Synchronized)]
325  [ComVisible(false)]
326  public override Task WriteAsync(char[] buffer, int index, int count)
327  {
328  Write(buffer, index, count);
329  return Task.CompletedTask;
330  }
331 
332  [MethodImpl(MethodImplOptions.Synchronized)]
333  [ComVisible(false)]
334  public override Task WriteLineAsync(char value)
335  {
336  WriteLine(value);
337  return Task.CompletedTask;
338  }
339 
340  [MethodImpl(MethodImplOptions.Synchronized)]
341  [ComVisible(false)]
342  public override Task WriteLineAsync(string value)
343  {
344  WriteLine(value);
345  return Task.CompletedTask;
346  }
347 
348  [MethodImpl(MethodImplOptions.Synchronized)]
349  [ComVisible(false)]
350  public override Task WriteLineAsync(char[] buffer, int index, int count)
351  {
352  WriteLine(buffer, index, count);
353  return Task.CompletedTask;
354  }
355 
356  [MethodImpl(MethodImplOptions.Synchronized)]
357  [ComVisible(false)]
358  public override Task FlushAsync()
359  {
360  Flush();
361  return Task.CompletedTask;
362  }
363  }
364 
366  [__DynamicallyInvokable]
367  public static readonly TextWriter Null = new NullTextWriter();
368 
369  [NonSerialized]
370  private static Action<object> _WriteCharDelegate = delegate(object state)
371  {
373  tuple6.Item1.Write(tuple6.Item2);
374  };
375 
376  [NonSerialized]
377  private static Action<object> _WriteStringDelegate = delegate(object state)
378  {
380  tuple5.Item1.Write(tuple5.Item2);
381  };
382 
383  [NonSerialized]
384  private static Action<object> _WriteCharArrayRangeDelegate = delegate(object state)
385  {
387  tuple4.Item1.Write(tuple4.Item2, tuple4.Item3, tuple4.Item4);
388  };
389 
390  [NonSerialized]
391  private static Action<object> _WriteLineCharDelegate = delegate(object state)
392  {
393  Tuple<TextWriter, char> tuple3 = (Tuple<TextWriter, char>)state;
394  tuple3.Item1.WriteLine(tuple3.Item2);
395  };
396 
397  [NonSerialized]
398  private static Action<object> _WriteLineStringDelegate = delegate(object state)
399  {
400  Tuple<TextWriter, string> tuple2 = (Tuple<TextWriter, string>)state;
401  tuple2.Item1.WriteLine(tuple2.Item2);
402  };
403 
404  [NonSerialized]
405  private static Action<object> _WriteLineCharArrayRangeDelegate = delegate(object state)
406  {
407  Tuple<TextWriter, char[], int, int> tuple = (Tuple<TextWriter, char[], int, int>)state;
408  tuple.Item1.WriteLine(tuple.Item2, tuple.Item3, tuple.Item4);
409  };
410 
411  [NonSerialized]
412  private static Action<object> _FlushDelegate = delegate(object state)
413  {
414  ((TextWriter)state).Flush();
415  };
416 
417  private const string InitialNewLine = "\r\n";
418 
420  [__DynamicallyInvokable]
421  protected char[] CoreNewLine = new char[2]
422  {
423  '\r',
424  '\n'
425  };
426 
427  private IFormatProvider InternalFormatProvider;
428 
431  [__DynamicallyInvokable]
432  public virtual IFormatProvider FormatProvider
433  {
434  [__DynamicallyInvokable]
435  get
436  {
437  if (InternalFormatProvider == null)
438  {
440  }
441  return InternalFormatProvider;
442  }
443  }
444 
447  [__DynamicallyInvokable]
448  public abstract Encoding Encoding
449  {
450  [__DynamicallyInvokable]
451  get;
452  }
453 
456  [__DynamicallyInvokable]
457  public virtual string NewLine
458  {
459  [__DynamicallyInvokable]
460  get
461  {
462  return new string(CoreNewLine);
463  }
464  [__DynamicallyInvokable]
465  set
466  {
467  if (value == null)
468  {
469  value = "\r\n";
470  }
471  CoreNewLine = value.ToCharArray();
472  }
473  }
474 
476  [__DynamicallyInvokable]
477  protected TextWriter()
478  {
479  InternalFormatProvider = null;
480  }
481 
484  [__DynamicallyInvokable]
485  protected TextWriter(IFormatProvider formatProvider)
486  {
487  InternalFormatProvider = formatProvider;
488  }
489 
491  public virtual void Close()
492  {
493  Dispose(disposing: true);
494  GC.SuppressFinalize(this);
495  }
496 
500  [__DynamicallyInvokable]
501  protected virtual void Dispose(bool disposing)
502  {
503  }
504 
506  [__DynamicallyInvokable]
507  public void Dispose()
508  {
509  Dispose(disposing: true);
510  GC.SuppressFinalize(this);
511  }
512 
514  [__DynamicallyInvokable]
515  public virtual void Flush()
516  {
517  }
518 
524  [HostProtection(SecurityAction.LinkDemand, Synchronization = true)]
525  public static TextWriter Synchronized(TextWriter writer)
526  {
527  if (writer == null)
528  {
529  throw new ArgumentNullException("writer");
530  }
531  if (writer is SyncTextWriter)
532  {
533  return writer;
534  }
535  return new SyncTextWriter(writer);
536  }
537 
542  [__DynamicallyInvokable]
543  public virtual void Write(char value)
544  {
545  }
546 
551  [__DynamicallyInvokable]
552  public virtual void Write(char[] buffer)
553  {
554  if (buffer != null)
555  {
556  Write(buffer, 0, buffer.Length);
557  }
558  }
559 
570  [__DynamicallyInvokable]
571  public virtual void Write(char[] buffer, int index, int count)
572  {
573  if (buffer == null)
574  {
575  throw new ArgumentNullException("buffer", Environment.GetResourceString("ArgumentNull_Buffer"));
576  }
577  if (index < 0)
578  {
579  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
580  }
581  if (count < 0)
582  {
583  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
584  }
585  if (buffer.Length - index < count)
586  {
587  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
588  }
589  for (int i = 0; i < count; i++)
590  {
591  Write(buffer[index + i]);
592  }
593  }
594 
599  [__DynamicallyInvokable]
600  public virtual void Write(bool value)
601  {
602  Write(value ? "True" : "False");
603  }
604 
609  [__DynamicallyInvokable]
610  public virtual void Write(int value)
611  {
612  Write(value.ToString(FormatProvider));
613  }
614 
619  [CLSCompliant(false)]
620  [__DynamicallyInvokable]
621  public virtual void Write(uint value)
622  {
623  Write(value.ToString(FormatProvider));
624  }
625 
630  [__DynamicallyInvokable]
631  public virtual void Write(long value)
632  {
633  Write(value.ToString(FormatProvider));
634  }
635 
640  [CLSCompliant(false)]
641  [__DynamicallyInvokable]
642  public virtual void Write(ulong value)
643  {
644  Write(value.ToString(FormatProvider));
645  }
646 
651  [__DynamicallyInvokable]
652  public virtual void Write(float value)
653  {
654  Write(value.ToString(FormatProvider));
655  }
656 
661  [__DynamicallyInvokable]
662  public virtual void Write(double value)
663  {
664  Write(value.ToString(FormatProvider));
665  }
666 
671  [__DynamicallyInvokable]
672  public virtual void Write(decimal value)
673  {
674  Write(value.ToString(FormatProvider));
675  }
676 
681  [__DynamicallyInvokable]
682  public virtual void Write(string value)
683  {
684  if (value != null)
685  {
686  Write(value.ToCharArray());
687  }
688  }
689 
694  [__DynamicallyInvokable]
695  public virtual void Write(object value)
696  {
697  if (value != null)
698  {
699  IFormattable formattable = value as IFormattable;
700  if (formattable != null)
701  {
702  Write(formattable.ToString(null, FormatProvider));
703  }
704  else
705  {
706  Write(value.ToString());
707  }
708  }
709  }
710 
720  [__DynamicallyInvokable]
721  public virtual void Write(string format, object arg0)
722  {
723  Write(string.Format(FormatProvider, format, arg0));
724  }
725 
736  [__DynamicallyInvokable]
737  public virtual void Write(string format, object arg0, object arg1)
738  {
739  Write(string.Format(FormatProvider, format, arg0, arg1));
740  }
741 
753  [__DynamicallyInvokable]
754  public virtual void Write(string format, object arg0, object arg1, object arg2)
755  {
756  Write(string.Format(FormatProvider, format, arg0, arg1, arg2));
757  }
758 
768  [__DynamicallyInvokable]
769  public virtual void Write(string format, params object[] arg)
770  {
771  Write(string.Format(FormatProvider, format, arg));
772  }
773 
777  [__DynamicallyInvokable]
778  public virtual void WriteLine()
779  {
781  }
782 
787  [__DynamicallyInvokable]
788  public virtual void WriteLine(char value)
789  {
790  Write(value);
791  WriteLine();
792  }
793 
798  [__DynamicallyInvokable]
799  public virtual void WriteLine(char[] buffer)
800  {
801  Write(buffer);
802  WriteLine();
803  }
804 
815  [__DynamicallyInvokable]
816  public virtual void WriteLine(char[] buffer, int index, int count)
817  {
818  Write(buffer, index, count);
819  WriteLine();
820  }
821 
826  [__DynamicallyInvokable]
827  public virtual void WriteLine(bool value)
828  {
829  Write(value);
830  WriteLine();
831  }
832 
837  [__DynamicallyInvokable]
838  public virtual void WriteLine(int value)
839  {
840  Write(value);
841  WriteLine();
842  }
843 
848  [CLSCompliant(false)]
849  [__DynamicallyInvokable]
850  public virtual void WriteLine(uint value)
851  {
852  Write(value);
853  WriteLine();
854  }
855 
860  [__DynamicallyInvokable]
861  public virtual void WriteLine(long value)
862  {
863  Write(value);
864  WriteLine();
865  }
866 
871  [CLSCompliant(false)]
872  [__DynamicallyInvokable]
873  public virtual void WriteLine(ulong value)
874  {
875  Write(value);
876  WriteLine();
877  }
878 
883  [__DynamicallyInvokable]
884  public virtual void WriteLine(float value)
885  {
886  Write(value);
887  WriteLine();
888  }
889 
894  [__DynamicallyInvokable]
895  public virtual void WriteLine(double value)
896  {
897  Write(value);
898  WriteLine();
899  }
900 
905  [__DynamicallyInvokable]
906  public virtual void WriteLine(decimal value)
907  {
908  Write(value);
909  WriteLine();
910  }
911 
916  [__DynamicallyInvokable]
917  public virtual void WriteLine(string value)
918  {
919  if (value == null)
920  {
921  WriteLine();
922  return;
923  }
924  int length = value.Length;
925  int num = CoreNewLine.Length;
926  char[] array = new char[length + num];
927  value.CopyTo(0, array, 0, length);
928  switch (num)
929  {
930  case 2:
931  array[length] = CoreNewLine[0];
932  array[length + 1] = CoreNewLine[1];
933  break;
934  case 1:
935  array[length] = CoreNewLine[0];
936  break;
937  default:
938  Buffer.InternalBlockCopy(CoreNewLine, 0, array, length * 2, num * 2);
939  break;
940  }
941  Write(array, 0, length + num);
942  }
943 
948  [__DynamicallyInvokable]
949  public virtual void WriteLine(object value)
950  {
951  if (value == null)
952  {
953  WriteLine();
954  return;
955  }
956  IFormattable formattable = value as IFormattable;
957  if (formattable != null)
958  {
959  WriteLine(formattable.ToString(null, FormatProvider));
960  }
961  else
962  {
963  WriteLine(value.ToString());
964  }
965  }
966 
976  [__DynamicallyInvokable]
977  public virtual void WriteLine(string format, object arg0)
978  {
979  WriteLine(string.Format(FormatProvider, format, arg0));
980  }
981 
992  [__DynamicallyInvokable]
993  public virtual void WriteLine(string format, object arg0, object arg1)
994  {
995  WriteLine(string.Format(FormatProvider, format, arg0, arg1));
996  }
997 
1009  [__DynamicallyInvokable]
1010  public virtual void WriteLine(string format, object arg0, object arg1, object arg2)
1011  {
1012  WriteLine(string.Format(FormatProvider, format, arg0, arg1, arg2));
1013  }
1014 
1023  [__DynamicallyInvokable]
1024  public virtual void WriteLine(string format, params object[] arg)
1025  {
1026  WriteLine(string.Format(FormatProvider, format, arg));
1027  }
1028 
1034  [ComVisible(false)]
1035  [__DynamicallyInvokable]
1036  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1037  public virtual Task WriteAsync(char value)
1038  {
1039  Tuple<TextWriter, char> state = new Tuple<TextWriter, char>(this, value);
1040  return Task.Factory.StartNew(_WriteCharDelegate, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
1041  }
1042 
1048  [ComVisible(false)]
1049  [__DynamicallyInvokable]
1050  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1051  public virtual Task WriteAsync(string value)
1052  {
1053  Tuple<TextWriter, string> state = new Tuple<TextWriter, string>(this, value);
1054  return Task.Factory.StartNew(_WriteStringDelegate, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
1055  }
1056 
1062  [ComVisible(false)]
1063  [__DynamicallyInvokable]
1064  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1065  public Task WriteAsync(char[] buffer)
1066  {
1067  if (buffer == null)
1068  {
1069  return Task.CompletedTask;
1070  }
1071  return WriteAsync(buffer, 0, buffer.Length);
1072  }
1073 
1086  [ComVisible(false)]
1087  [__DynamicallyInvokable]
1088  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1089  public virtual Task WriteAsync(char[] buffer, int index, int count)
1090  {
1091  Tuple<TextWriter, char[], int, int> state = new Tuple<TextWriter, char[], int, int>(this, buffer, index, count);
1092  return Task.Factory.StartNew(_WriteCharArrayRangeDelegate, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
1093  }
1094 
1100  [ComVisible(false)]
1101  [__DynamicallyInvokable]
1102  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1103  public virtual Task WriteLineAsync(char value)
1104  {
1105  Tuple<TextWriter, char> state = new Tuple<TextWriter, char>(this, value);
1106  return Task.Factory.StartNew(_WriteLineCharDelegate, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
1107  }
1108 
1114  [ComVisible(false)]
1115  [__DynamicallyInvokable]
1116  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1117  public virtual Task WriteLineAsync(string value)
1118  {
1119  Tuple<TextWriter, string> state = new Tuple<TextWriter, string>(this, value);
1120  return Task.Factory.StartNew(_WriteLineStringDelegate, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
1121  }
1122 
1128  [ComVisible(false)]
1129  [__DynamicallyInvokable]
1130  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1131  public Task WriteLineAsync(char[] buffer)
1132  {
1133  if (buffer == null)
1134  {
1135  return Task.CompletedTask;
1136  }
1137  return WriteLineAsync(buffer, 0, buffer.Length);
1138  }
1139 
1152  [ComVisible(false)]
1153  [__DynamicallyInvokable]
1154  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1155  public virtual Task WriteLineAsync(char[] buffer, int index, int count)
1156  {
1157  Tuple<TextWriter, char[], int, int> state = new Tuple<TextWriter, char[], int, int>(this, buffer, index, count);
1158  return Task.Factory.StartNew(_WriteLineCharArrayRangeDelegate, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
1159  }
1160 
1165  [ComVisible(false)]
1166  [__DynamicallyInvokable]
1167  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1168  public virtual Task WriteLineAsync()
1169  {
1170  return WriteAsync(CoreNewLine);
1171  }
1172 
1177  [ComVisible(false)]
1178  [__DynamicallyInvokable]
1179  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
1180  public virtual Task FlushAsync()
1181  {
1182  return Task.Factory.StartNew(_FlushDelegate, this, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
1183  }
1184  }
1185 }
Represents a character encoding.To browse the .NET Framework source code for this type,...
Definition: Encoding.cs:15
static Thread CurrentThread
Gets the currently running thread.
Definition: Thread.cs:134
static new TaskFactory< TResult > Factory
Provides access to factory methods for creating and configuring T:System.Threading....
Definition: Task.cs:75
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Definition: CultureInfo.cs:263
virtual void WriteLine(bool value)
Writes the text representation of a Boolean value followed by a line terminator to the text string or...
Definition: TextWriter.cs:827
virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.IO.TextWriter and optionally releases the manag...
Definition: TextWriter.cs:501
virtual Task WriteAsync(char value)
Writes a character to the text string or stream asynchronously.
Definition: TextWriter.cs:1037
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
virtual void Write(uint value)
Writes the text representation of a 4-byte unsigned integer to the text string or stream.
Definition: TextWriter.cs:621
Task WriteLineAsync(char[] buffer)
Writes an array of characters followed by a line terminator asynchronously to the text string or stre...
Definition: TextWriter.cs:1131
virtual void WriteLine(float value)
Writes the text representation of a 4-byte floating-point value followed by a line terminator to the ...
Definition: TextWriter.cs:884
Propagates notification that operations should be canceled.
virtual void WriteLine(char value)
Writes a character followed by a line terminator to the text string or stream.
Definition: TextWriter.cs:788
virtual void Write(decimal value)
Writes the text representation of a decimal value to the text string or stream.
Definition: TextWriter.cs:672
Provides static methods for creating tuple objects. To browse the .NET Framework source code for this...
Definition: Tuple.cs:10
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
Definition: GC.cs:308
Task WriteAsync(char[] buffer)
Writes a character array to the text string or stream asynchronously.
Definition: TextWriter.cs:1065
static Encoding Default
Gets an encoding for the operating system's current ANSI code page.
Definition: Encoding.cs:959
virtual void WriteLine(string format, object arg0)
Writes a formatted string and a new line to the text string or stream, using the same semantics as th...
Definition: TextWriter.cs:977
virtual void WriteLine(uint value)
Writes the text representation of a 4-byte unsigned integer followed by a line terminator to the text...
Definition: TextWriter.cs:850
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Definition: IDisposable.cs:8
TextWriter(IFormatProvider formatProvider)
Initializes a new instance of the T:System.IO.TextWriter class with the specified format provider.
Definition: TextWriter.cs:485
virtual void Write(int value)
Writes the text representation of a 4-byte signed integer to the text string or stream.
Definition: TextWriter.cs:610
Represents an object that handles the low-level work of queuing tasks onto threads.
Definition: __Canon.cs:3
The exception that is thrown when the value of an argument is outside the allowable range of values a...
TextWriter()
Initializes a new instance of the T:System.IO.TextWriter class.
Definition: TextWriter.cs:477
virtual void Write(float value)
Writes the text representation of a 4-byte floating-point value to the text string or stream.
Definition: TextWriter.cs:652
Provides a mechanism for retrieving an object to control formatting.
virtual Task WriteAsync(string value)
Writes a string to the text string or stream asynchronously.
Definition: TextWriter.cs:1051
string ToString(string format, IFormatProvider formatProvider)
Formats the value of the current instance using the specified format.
void Dispose()
Releases all resources used by the T:System.IO.TextWriter object.
Definition: TextWriter.cs:507
TaskCreationOptions
Specifies flags that control optional behavior for the creation and execution of tasks.
virtual Task WriteLineAsync(char[] buffer, int index, int count)
Writes a subarray of characters followed by a line terminator asynchronously to the text string or st...
Definition: TextWriter.cs:1155
virtual void Write(bool value)
Writes the text representation of a Boolean value to the text string or stream.
Definition: TextWriter.cs:600
static TaskScheduler Default
Gets the default T:System.Threading.Tasks.TaskScheduler instance that is provided by the ....
SecurityAction
Specifies the security actions that can be performed using declarative security.
CultureInfo?? CurrentCulture
Gets or sets the culture for the current thread.
Definition: Thread.cs:245
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
virtual Task WriteLineAsync(string value)
Writes a string followed by a line terminator asynchronously to the text string or stream.
Definition: TextWriter.cs:1117
virtual void WriteLine(ulong value)
Writes the text representation of an 8-byte unsigned integer followed by a line terminator to the tex...
Definition: TextWriter.cs:873
virtual void Write(double value)
Writes the text representation of an 8-byte floating-point value to the text string or stream.
Definition: TextWriter.cs:662
virtual void WriteLine(char[] buffer)
Writes an array of characters followed by a line terminator to the text string or stream.
Definition: TextWriter.cs:799
virtual void Write(string format, object arg0)
Writes a formatted string to the text string or stream, using the same semantics as the M:System....
Definition: TextWriter.cs:721
virtual void Write(ulong value)
Writes the text representation of an 8-byte unsigned integer to the text string or stream.
Definition: TextWriter.cs:642
Represents a writer that can write a sequential series of characters. This class is abstract.
Definition: TextWriter.cs:15
virtual void Write(object value)
Writes the text representation of an object to the text string or stream by calling the ToString meth...
Definition: TextWriter.cs:695
virtual void Write(long value)
Writes the text representation of an 8-byte signed integer to the text string or stream.
Definition: TextWriter.cs:631
virtual void WriteLine(decimal value)
Writes the text representation of a decimal value followed by a line terminator to the text string or...
Definition: TextWriter.cs:906
virtual void Write(char[] buffer, int index, int count)
Writes a subarray of characters to the text string or stream.
Definition: TextWriter.cs:571
virtual void WriteLine(long value)
Writes the text representation of an 8-byte signed integer followed by a line terminator to the text ...
Definition: TextWriter.cs:861
virtual void Write(char[] buffer)
Writes a character array to the text string or stream.
Definition: TextWriter.cs:552
static Task CompletedTask
Gets a task that has already completed successfully.
Definition: Task.cs:1453
MethodImplOptions
Defines the details of how a method is implemented.
virtual string NewLine
Gets or sets the line terminator string used by the current TextWriter.
Definition: TextWriter.cs:458
virtual void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
Definition: TextWriter.cs:515
static CancellationToken None
Returns an empty T:System.Threading.CancellationToken value.
char [] CoreNewLine
Stores the newline characters used for this TextWriter.
Definition: TextWriter.cs:421
Controls the system garbage collector, a service that automatically reclaims unused memory.
Definition: GC.cs:11
The exception that is thrown when one of the arguments provided to a method is not valid.
virtual void WriteLine(string format, object arg0, object arg1, object arg2)
Writes out a formatted string and a new line, using the same semantics as M:System....
Definition: TextWriter.cs:1010
virtual void WriteLine(object value)
Writes the text representation of an object by calling the ToString method on that object,...
Definition: TextWriter.cs:949
virtual void WriteLine(string format, object arg0, object arg1)
Writes a formatted string and a new line to the text string or stream, using the same semantics as th...
Definition: TextWriter.cs:993
virtual void Write(string value)
Writes a string to the text string or stream.
Definition: TextWriter.cs:682
virtual void WriteLine(string value)
Writes a string followed by a line terminator to the text string or stream.
Definition: TextWriter.cs:917
virtual Task FlushAsync()
Asynchronously clears all buffers for the current writer and causes any buffered data to be written t...
Definition: TextWriter.cs:1180
virtual void Write(string format, params object[] arg)
Writes a formatted string to the text string or stream, using the same semantics as the M:System....
Definition: TextWriter.cs:769
static TextWriter Synchronized(TextWriter writer)
Creates a thread-safe wrapper around the specified TextWriter.
Definition: TextWriter.cs:525
Specifies that the class can be serialized.
virtual void WriteLine(int value)
Writes the text representation of a 4-byte signed integer followed by a line terminator to the text s...
Definition: TextWriter.cs:838
virtual void WriteLine()
Writes a line terminator to the text string or stream.
Definition: TextWriter.cs:778
virtual void Close()
Closes the current writer and releases any system resources associated with the writer.
Definition: TextWriter.cs:491
virtual void WriteLine(string format, params object[] arg)
Writes out a formatted string and a new line, using the same semantics as M:System....
Definition: TextWriter.cs:1024
virtual void WriteLine(char[] buffer, int index, int count)
Writes a subarray of characters followed by a line terminator to the text string or stream.
Definition: TextWriter.cs:816
virtual Task WriteAsync(char[] buffer, int index, int count)
Writes a subarray of characters to the text string or stream asynchronously.
Definition: TextWriter.cs:1089
Manipulates arrays of primitive types.
Definition: Buffer.cs:11
virtual void Write(string format, object arg0, object arg1)
Writes a formatted string to the text string or stream, using the same semantics as the M:System....
Definition: TextWriter.cs:737
Encoding()
Initializes a new instance of the T:System.Text.Encoding class.
Definition: Encoding.cs:1053
static readonly TextWriter Null
Provides a TextWriter with no backing store that can be written to, but not read from.
Definition: TextWriter.cs:367
virtual void WriteLine(double value)
Writes the text representation of a 8-byte floating-point value followed by a line terminator to the ...
Definition: TextWriter.cs:895
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
virtual Task WriteLineAsync()
Writes a line terminator asynchronously to the text string or stream.
Definition: TextWriter.cs:1168
virtual void Write(char value)
Writes a character to the text string or stream.
Definition: TextWriter.cs:543
Provides functionality to format the value of an object into a string representation.
Definition: IFormattable.cs:8
virtual Task WriteLineAsync(char value)
Writes a character followed by a line terminator asynchronously to the text string or stream.
Definition: TextWriter.cs:1103
virtual IFormatProvider FormatProvider
Gets an object that controls formatting.
Definition: TextWriter.cs:433
virtual void Write(string format, object arg0, object arg1, object arg2)
Writes a formatted string to the text string or stream, using the same semantics as the M:System....
Definition: TextWriter.cs:754
Represents an asynchronous operation that can return a value.
Definition: Task.cs:18
Enables access to objects across application domain boundaries in applications that support remoting.
Creates and controls a thread, sets its priority, and gets its status.
Definition: Thread.cs:18