Table of Contents

Class TextReaderExtensions

Namespace
Cuemon.Extensions.IO
Assembly
Cuemon.Extensions.IO.dll

Extension methods for the System.IO.TextReader class.

public static class TextReaderExtensions
Inheritance
Object
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 TextReader

The System.IO.TextReader to extend.

writer TextWriter

The System.IO.TextWriter to asynchronously write bytes to.

bufferSize Int32

The 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

System.ArgumentNullException

reader cannot be null -or- writer cannot be null.

System.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 TextReader

The System.IO.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 TextReader

The System.IO.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.