Table of Contents

Class TabularWriter<T>

Namespace
Addax.Formats.Tabular
Assembly
Addax.Formats.Tabular.dll

Provides forward-only, write-only access to tabular data records. This class cannot be inherited.

public sealed class TabularWriter<T> : IDisposable, IAsyncDisposable where T : notnull

Type Parameters

T

The type of an object that represents a record.

Inheritance
TabularWriter<T>
Implements

Constructors

TabularWriter(Stream, TabularDialect, TabularOptions?, TabularHandler<T>?)

Initializes a new instance of the TabularWriter<T> class for the specified stream using the provided dialect, options, and record handler.

public TabularWriter(Stream stream, TabularDialect dialect, TabularOptions? options = null, TabularHandler<T>? handler = null)

Parameters

stream Stream

The stream to write to.

dialect TabularDialect

The dialect to use for writing.

options TabularOptions

The options to control the behavior during writing.

handler TabularHandler<T>

The handler to write a T instance to a record.

Exceptions

ArgumentException

stream does not support writing.

ArgumentNullException

stream or dialect is null.

InvalidOperationException

The record handler is not specified and cannot be found in the registry.

Properties

BytesCommitted

Gets the number of bytes committed so far.

public long BytesCommitted { get; }

Property Value

long

A non-negative 64-bit signed integer.

Remarks

Might be greater than the number of bytes written to the underlying stream.

RecordsWritten

Gets the number of records written so far.

public long RecordsWritten { get; }

Property Value

long

A non-negative 64-bit signed integer.

Methods

Dispose()

Releases the resources used by the current instance of the TabularWriter<T> class.

public void Dispose()

Remarks

If the record handler defines a header, it will be automatically written.

DisposeAsync()

Asynchronously releases the resources used by the current instance of the TabularWriter<T> class.

public ValueTask DisposeAsync()

Returns

ValueTask

A task object.

Remarks

If the record handler defines a header, it will be automatically written.

Flush()

Writes any buffered data to the underlying stream.

public void Flush()

FlushAsync(CancellationToken)

Asynchronously writes any buffered data to the underlying stream.

public ValueTask FlushAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

ValueTask

A task object.

Exceptions

OperationCanceledException

The cancellation token was canceled. This exception is stored into the returned task.

WriteRecord(in T)

Writes the next record represented as T.

public void WriteRecord(in T record)

Parameters

record T

The record to write.

Remarks

If the record handler defines a header, it will be automatically written.

Exceptions

ArgumentNullException

record is null.

WriteRecordAsync(T, CancellationToken)

Asynchronously writes the next record represented as T.

public ValueTask WriteRecordAsync(T record, CancellationToken cancellationToken = default)

Parameters

record T

The record to write.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

ValueTask

A task object.

Remarks

If the record handler defines a header, it will be automatically written.

Exceptions

ArgumentNullException

record is null.

OperationCanceledException

The cancellation token was canceled. This exception is stored into the returned task.