Class TextReaderExtensions
- Namespace
- Cuemon.Extensions.IO
- Assembly
- Cuemon.Extensions.IO.dll
Extension methods for the TextReader class.
public static class TextReaderExtensions
- Inheritance
-
TextReaderExtensions
Methods
CopyToAsync(TextReader, TextWriter, Int32)
Asynchronously reads the bytes from the reader
and writes them to the writer
.
public static Task CopyToAsync(this TextReader reader, TextWriter writer, int bufferSize = 81920)
Parameters
reader
TextReaderThe TextReader to extend.
writer
TextWriterThe TextWriter to asynchronously write bytes to.
bufferSize
Int32The size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.
Returns
- Task
A task that represents the asynchronous copy operation.
Exceptions
- ArgumentNullException
reader
cannot be null -or-writer
cannot be null.- ArgumentOutOfRangeException
bufferSize
is lower than or equal to 0.
ReadAllLines(TextReader)
Reads all lines of characters from the reader
and returns the data as a sequence of strings.
public static IEnumerable<string> ReadAllLines(this TextReader reader)
Parameters
reader
TextReaderThe TextReader to extend.
Returns
- IEnumerable<String>
An IEnumerable{string} that contains all lines of characters from the
reader
.
ReadAllLinesAsync(TextReader)
Asynchronously reads all lines of characters from the reader
and returns the data as a sequence of strings.
public static async Task<IReadOnlyList<string>> ReadAllLinesAsync(this TextReader reader)
Parameters
reader
TextReaderThe TextReader to extend.
Returns
- Task<IReadOnlyList<String>>
A task that represents the asynchronous operation. The task result contains a IReadOnlyList{string} that contains all lines of characters from the
reader
that contains elements from the input sequence.