13 [__DynamicallyInvokable]
17 private sealed
class NullTextReader :
TextReader 19 public override int Read(
char[] buffer,
int index,
int count)
31 internal sealed
class SyncTextReader :
TextReader 41 public override void Close()
47 protected override void Dispose(
bool disposing)
56 public override int Peek()
62 public override int Read()
68 public override int Read([In] [Out]
char[] buffer,
int index,
int count)
70 return _in.Read(buffer, index, count);
74 public override int ReadBlock([In] [Out]
char[] buffer,
int index,
int count)
76 return _in.ReadBlock(buffer, index, count);
82 return _in.ReadLine();
88 return _in.ReadToEnd();
113 if (index < 0 || count < 0)
117 if (buffer.Length - index < count)
132 if (index < 0 || count < 0)
136 if (buffer.Length - index < count)
140 return Task.FromResult(
Read(buffer, index, count));
145 private static Func<object, string> _ReadLineDelegate = (
object state) => ((
TextReader)state).
ReadLine();
148 private static Func<object, int> _ReadDelegate = delegate(
object state)
151 return tuple.Item1.Read(tuple.Item2, tuple.Item3, tuple.Item4);
155 [__DynamicallyInvokable]
159 [__DynamicallyInvokable]
172 [__DynamicallyInvokable]
182 [__DynamicallyInvokable]
183 protected virtual void Dispose(
bool disposing)
191 [__DynamicallyInvokable]
201 [__DynamicallyInvokable]
219 [__DynamicallyInvokable]
220 public virtual int Read([In] [Out]
char[] buffer,
int index,
int count)
234 if (buffer.Length - index < count)
246 buffer[index + num++] = (char)num2;
258 [__DynamicallyInvokable]
261 char[] array =
new char[4096];
264 while ((charCount =
Read(array, 0, array.Length)) != 0)
266 stringBuilder.
Append(array, 0, charCount);
283 [__DynamicallyInvokable]
284 public virtual int ReadBlock([In] [Out]
char[] buffer,
int index,
int count)
290 num += (num2 =
Read(buffer, index + num, count - num));
292 while (num2 > 0 && num < count);
302 [__DynamicallyInvokable]
313 if (num == 13 &&
Peek() == 10)
319 if (stringBuilder.
Length > 0)
325 stringBuilder.
Append((
char)num);
335 [__DynamicallyInvokable]
336 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
348 [__DynamicallyInvokable]
349 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
352 char[] chars =
new char[4096];
355 while ((len = await ReadAsyncInternal(chars, 0, chars.Length).
ConfigureAwait(continueOnCapturedContext:
false)) != 0)
375 [__DynamicallyInvokable]
376 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
383 if (index < 0 || count < 0)
387 if (buffer.Length - index < count)
391 return ReadAsyncInternal(buffer, index, count);
394 internal virtual Task<int> ReadAsyncInternal(
char[] buffer,
int index,
int count)
413 [__DynamicallyInvokable]
414 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
421 if (index < 0 || count < 0)
425 if (buffer.Length - index < count)
429 return ReadBlockAsyncInternal(buffer, index, count);
432 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
433 private async
Task<int> ReadBlockAsyncInternal(
char[] buffer,
int index,
int count)
439 num = await ReadAsyncInternal(buffer, index + i, count - i).
ConfigureAwait(continueOnCapturedContext:
false);
442 while (num > 0 && i < count);
451 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true)]
458 if (reader is SyncTextReader)
462 return new SyncTextReader(reader);
static new TaskFactory< TResult > Factory
Provides access to factory methods for creating and configuring T:System.Threading....
virtual void Close()
Closes the T:System.IO.TextReader and releases any system resources associated with the TextReader.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Propagates notification that operations should be canceled.
virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.IO.TextReader and optionally releases the manag...
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Configures an awaiter used to await this T:System.Threading.Tasks.Task`1.
virtual Task< string > ReadLineAsync()
Reads a line of characters asynchronously and returns the data as a string.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
Provides static methods for creating tuple objects. To browse the .NET Framework source code for this...
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
virtual string ReadToEnd()
Reads all characters from the current position to the end of the text reader and returns them as one ...
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
virtual async Task< string > ReadToEndAsync()
Reads all characters from the current position to the end of the text reader asynchronously and retur...
Represents an object that handles the low-level work of queuing tasks onto threads.
virtual Task< int > ReadBlockAsync(char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current text reader asynchronously and writes...
The exception that is thrown when the value of an argument is outside the allowable range of values a...
virtual int Read([In] [Out] char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current reader and writes the data to a buffe...
TaskCreationOptions
Specifies flags that control optional behavior for the creation and execution of tasks.
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.
Provides information about, and means to manipulate, the current environment and platform....
static readonly TextReader Null
Provides a TextReader with no data to read from.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
virtual int Read()
Reads the next character from the text reader and advances the character position by one character.
int Length
Gets or sets the length of the current T:System.Text.StringBuilder object.
virtual int ReadBlock([In] [Out] char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current text reader and writes the data to a ...
void Dispose()
Releases all resources used by the T:System.IO.TextReader object.
MethodImplOptions
Defines the details of how a method is implemented.
virtual Task< int > ReadAsync(char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current text reader asynchronously and writes...
static CancellationToken None
Returns an empty T:System.Threading.CancellationToken value.
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
Controls the system garbage collector, a service that automatically reclaims unused memory.
The exception that is thrown when one of the arguments provided to a method is not valid.
TextReader()
Initializes a new instance of the T:System.IO.TextReader class.
Represents a reader that can read a sequential series of characters.
static TextReader Synchronized(TextReader reader)
Creates a thread-safe wrapper around the specified TextReader.
virtual int Peek()
Reads the next character without changing the state of the reader or the character source....
Specifies that the class can be serialized.
virtual string ReadLine()
Reads a line of characters from the text reader and returns the data as a string.
Represents an asynchronous operation that can return a value.
Enables access to objects across application domain boundaries in applications that support remoting.