Class CesilUtils

A collection of convenience methods for reading and writing using streams or files.

These methods are less flexible than directly using Configuration and are not as efficient as using IReader(T), IAsyncReader(T), IWriter(T) and IAsyncWriter(T), but they involve much less code.

Prefer them when the trade off for simplicity at the expense speed and flexibility makes sense.

Inheritance
System.Object
CesilUtils
Namespace: Cesil
Assembly: Cesil.dll
Syntax
public static class CesilUtils : Object

Methods

Enumerate<TRow>(TextReader, Options, Object)

Lazily enumerate rows of type TRow from the given TextReader.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

Declaration
public static IEnumerable<TRow> Enumerate<TRow>(TextReader reader, Options options = null, object context = null)
Parameters
Type Name Description
System.IO.TextReader reader
Options options
System.Object context
Returns
Type Description
System.Collections.Generic.IEnumerable<TRow>
Type Parameters
Name Description
TRow

EnumerateAsync<TRow>(TextReader, Options, Object, CancellationToken)

Lazily and asynchronously enumerate rows of type TRow from the given TextReader.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static IAsyncEnumerable<TRow> EnumerateAsync<TRow>(TextReader reader, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.IO.TextReader reader
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<TRow>
Type Parameters
Name Description
TRow

EnumerateDynamic(TextReader, Options, Object)

Lazily enumerate dynamic rows from the given TextReader.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

Declaration
public static IEnumerable<dynamic> EnumerateDynamic(TextReader reader, Options options = null, object context = null)
Parameters
Type Name Description
System.IO.TextReader reader
Options options
System.Object context
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Object>

EnumerateDynamicAsync(TextReader, Options, Object, CancellationToken)

Lazily and asynchronously enumerate dynamic rows from the given TextReader.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static IAsyncEnumerable<dynamic> EnumerateDynamicAsync(TextReader reader, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.IO.TextReader reader
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<System.Object>

EnumerateDynamicFromFile(String, Options, Object)

Lazily enumerate dynamic rows from the given file. If the file as a byte-order-marker (BOM) the indicated encoding will be used, otherwise utf-8 will be assumed.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

Declaration
public static IEnumerable<dynamic> EnumerateDynamicFromFile(string path, Options options = null, object context = null)
Parameters
Type Name Description
System.String path
Options options
System.Object context
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Object>

EnumerateDynamicFromFileAsync(String, Options, Object, CancellationToken)

Lazily and asynchronously enumerate dynamic rows from the given file. If the file as a byte-order-marker (BOM) the indicated encoding will be used, otherwise utf-8 will be assumed.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static IAsyncEnumerable<dynamic> EnumerateDynamicFromFileAsync(string path, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String path
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<System.Object>

EnumerateDynamicFromString(String, Options, Object)

Lazily enumerate dynamic rows from the given string.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

Declaration
public static IEnumerable<dynamic> EnumerateDynamicFromString(string data, Options options = null, object context = null)
Parameters
Type Name Description
System.String data
Options options
System.Object context
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Object>

EnumerateDynamicFromStringAsync(String, Options, Object, CancellationToken)

Lazily and asynchronously enumerate dynamic rows from the given string.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static IAsyncEnumerable<dynamic> EnumerateDynamicFromStringAsync(string data, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String data
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<System.Object>

EnumerateFromFile<TRow>(String, Options, Object)

Lazily enumerate rows of type TRow from the given file. If the file as a byte-order-marker (BOM) the indicated encoding will be used, otherwise utf-8 will be assumed.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

Declaration
public static IEnumerable<TRow> EnumerateFromFile<TRow>(string path, Options options = null, object context = null)
Parameters
Type Name Description
System.String path
Options options
System.Object context
Returns
Type Description
System.Collections.Generic.IEnumerable<TRow>
Type Parameters
Name Description
TRow

EnumerateFromFileAsync<TRow>(String, Options, Object, CancellationToken)

Lazily and asynchronously enumerate rows of type TRow from the given file. If the file as a byte-order-marker (BOM) the indicated encoding will be used, otherwise utf-8 will be assumed.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static IAsyncEnumerable<TRow> EnumerateFromFileAsync<TRow>(string path, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String path
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<TRow>
Type Parameters
Name Description
TRow

EnumerateFromString<TRow>(String, Options, Object)

Lazily enumerate rows of type TRow from the given string.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

Declaration
public static IEnumerable<TRow> EnumerateFromString<TRow>(string data, Options options = null, object context = null)
Parameters
Type Name Description
System.String data
Options options
System.Object context
Returns
Type Description
System.Collections.Generic.IEnumerable<TRow>
Type Parameters
Name Description
TRow

EnumerateFromStringAsync<TRow>(String, Options, Object, CancellationToken)

Lazily and asynchronously enumerate rows of type TRow from the given string.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on ReadContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static IAsyncEnumerable<TRow> EnumerateFromStringAsync<TRow>(string data, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String data
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<TRow>
Type Parameters
Name Description
TRow

Write<TRow>(IEnumerable<TRow>, TextWriter, Options, Object)

Write a collection of rows of TRow to the given TextWriter.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

Declaration
public static void Write<TRow>(IEnumerable<TRow> rows, TextWriter writer, Options options = null, object context = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TRow> rows
System.IO.TextWriter writer
Options options
System.Object context
Type Parameters
Name Description
TRow

WriteAsync<TRow>(IAsyncEnumerable<TRow>, TextWriter, Options, Object, CancellationToken)

Write a collection of rows of TRow to the given TextWriter asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteAsync<TRow>(IAsyncEnumerable<TRow> rows, TextWriter writer, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<TRow> rows
System.IO.TextWriter writer
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
TRow

WriteAsync<TRow>(IEnumerable<TRow>, TextWriter, Options, Object, CancellationToken)

Write a collection of rows of TRow to the given TextWriter asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteAsync<TRow>(IEnumerable<TRow> rows, TextWriter writer, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TRow> rows
System.IO.TextWriter writer
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
TRow

WriteDynamic(IEnumerable<Object>, TextWriter, Options, Object)

Write a collection of dynamic rows to the given TextWriter.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

Declaration
public static void WriteDynamic(IEnumerable<dynamic> rows, TextWriter writer, Options options = null, object context = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Object> rows
System.IO.TextWriter writer
Options options
System.Object context

WriteDynamicAsync(IAsyncEnumerable<Object>, TextWriter, Options, Object, CancellationToken)

Write a collection of dynamics rows to the given TextWriter asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteDynamicAsync(IAsyncEnumerable<dynamic> rows, TextWriter writer, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<System.Object> rows
System.IO.TextWriter writer
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask

WriteDynamicAsync(IEnumerable<Object>, TextWriter, Options, Object, CancellationToken)

Write a collection of dynamic rows to the given TextWriter asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteDynamicAsync(IEnumerable<dynamic> rows, TextWriter writer, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Object> rows
System.IO.TextWriter writer
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask

WriteDynamicToFile(IEnumerable<Object>, String, Options, Object)

Write a collection of dynamic rows to the given path.

The file be created if it does not existing, overwritten if it does, and the encoding used will be utf-8.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

Declaration
public static void WriteDynamicToFile(IEnumerable<dynamic> rows, string path, Options options = null, object context = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Object> rows
System.String path
Options options
System.Object context

WriteDynamicToFileAsync(IAsyncEnumerable<Object>, String, Options, Object, CancellationToken)

Write a collection of dynamic rows to the given path asynchronously.

The file be created if it does not existing, overwritten if it does, and the encoding used will be utf-8.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteDynamicToFileAsync(IAsyncEnumerable<dynamic> rows, string path, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<System.Object> rows
System.String path
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask

WriteDynamicToFileAsync(IEnumerable<Object>, String, Options, Object, CancellationToken)

Write a collection of dynamic rows to the given path asynchronously.

The file be created if it does not existing, overwritten if it does, and the encoding used will be utf-8.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteDynamicToFileAsync(IEnumerable<dynamic> rows, string path, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Object> rows
System.String path
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask

WriteDynamicToString(IEnumerable<Object>, Options, Object)

Write a collection of dynamic rows to a string.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

Declaration
public static string WriteDynamicToString(IEnumerable<dynamic> rows, Options options = null, object context = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Object> rows
Options options
System.Object context
Returns
Type Description
System.String

WriteDynamicToStringAsync(IAsyncEnumerable<Object>, Options, Object, CancellationToken)

Write a collection of dynamic rows to a string asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask<string> WriteDynamicToStringAsync(IAsyncEnumerable<dynamic> rows, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<System.Object> rows
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask<System.String>

WriteDynamicToStringAsync(IEnumerable<Object>, Options, Object, CancellationToken)

Write a collection of dynamic rows to a string asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask<string> WriteDynamicToStringAsync(IEnumerable<dynamic> rows, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Object> rows
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask<System.String>

WriteToFile<TRow>(IEnumerable<TRow>, String, Options, Object)

Write a collection of rows of TRow to the given path.

The file be created if it does not existing, overwritten if it does, and the encoding used will be utf-8.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

Declaration
public static void WriteToFile<TRow>(IEnumerable<TRow> rows, string path, Options options = null, object context = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TRow> rows
System.String path
Options options
System.Object context
Type Parameters
Name Description
TRow

WriteToFileAsync<TRow>(IAsyncEnumerable<TRow>, String, Options, Object, CancellationToken)

Write a collection of rows of TRow to the given path asynchronously.

The file be created if it does not existing, overwritten if it does, and the encoding used will be utf-8.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteToFileAsync<TRow>(IAsyncEnumerable<TRow> rows, string path, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<TRow> rows
System.String path
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
TRow

WriteToFileAsync<TRow>(IEnumerable<TRow>, String, Options, Object, CancellationToken)

Write a collection of rows of TRow to the given path asynchronously.

The file be created if it does not existing, overwritten if it does, and the encoding used will be utf-8.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask WriteToFileAsync<TRow>(IEnumerable<TRow> rows, string path, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TRow> rows
System.String path
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
TRow

WriteToString<TRow>(IEnumerable<TRow>, Options, Object)

Write a collection of rows of TRow to a string.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

Declaration
public static string WriteToString<TRow>(IEnumerable<TRow> rows, Options options = null, object context = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TRow> rows
Options options
System.Object context
Returns
Type Description
System.String
Type Parameters
Name Description
TRow

WriteToStringAsync<TRow>(IAsyncEnumerable<TRow>, Options, Object, CancellationToken)

Write a collection of rows of TRow to a string asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask<string> WriteToStringAsync<TRow>(IAsyncEnumerable<TRow> rows, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<TRow> rows
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask<System.String>
Type Parameters
Name Description
TRow

WriteToStringAsync<TRow>(IEnumerable<TRow>, Options, Object, CancellationToken)

Write a collection of rows of TRow to a string asynchronously.

An optional Options object may be used, if not provided Options.Default will be used.

Takes an optional context object which is made available during certain operations as a member on WriteContext.

A CancellationToken may also be provided, CancellationToken.None will be used otherwise.

Declaration
public static ValueTask<string> WriteToStringAsync<TRow>(IEnumerable<TRow> rows, Options options = null, object context = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TRow> rows
Options options
System.Object context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.ValueTask<System.String>
Type Parameters
Name Description
TRow
In This Article
Back to top Generated by DocFX