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, int)
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
readerTextReaderThe TextReader to extend.
writerTextWriterThe TextWriter to asynchronously write bytes to.
bufferSizeintThe 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
readercannot be null -or-writercannot be null.- ArgumentOutOfRangeException
bufferSizeis 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
readerTextReaderThe 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 Task<IReadOnlyList<string>> ReadAllLinesAsync(this TextReader reader)
Parameters
readerTextReaderThe 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
readerthat contains elements from the input sequence.