Table of Contents

Class FileSink<TSource, TWriter>

Namespace
Bonsai.IO
Assembly
Bonsai.System.dll

Provides a base class for sinks that write the elements from the input sequence into a file.

public abstract class FileSink<TSource, TWriter> : FileSink where TWriter : class, IDisposable

Type Parameters

TSource

The type of the elements in the source sequence.

TWriter

The type of writer that should be used to write the elements.

Inheritance
FileSink<TSource, TWriter>
Derived
Inherited Members

Methods

CreateWriter(string, TSource)

When overridden in a derived class, creates the writer over the specified fileName that will be responsible for handling the input elements.

protected abstract TWriter CreateWriter(string fileName, TSource input)

Parameters

fileName string

The name of the file on which the elements should be written.

input TSource

The first input element that needs to be pushed into the file.

Returns

TWriter

The writer that will be used to push elements into the file.

Process(IObservable<TSource>)

Writes all elements of an observable sequence to the specified file.

public virtual IObservable<TSource> Process(IObservable<TSource> source)

Parameters

source IObservable<TSource>

The sequence of elements to write to the file.

Returns

IObservable<TSource>

An observable sequence that is identical to the source sequence but where there is an additional side effect of writing the elements to a file.

Process<TElement>(IObservable<TElement>, Func<TElement, TSource>)

Writes all elements of an observable sequence to a file.

protected IObservable<TElement> Process<TElement>(IObservable<TElement> source, Func<TElement, TSource> selector)

Parameters

source IObservable<TElement>

The sequence of elements to write to the file.

selector Func<TElement, TSource>

The transform function used to convert each element of the sequence into the type of inputs accepted by the file writer.

Returns

IObservable<TElement>

An observable sequence that is identical to the source sequence but where there is an additional side effect of writing the elements to a file.

Type Parameters

TElement

The type of the elements in the source sequence.

Exceptions

ArgumentNullException

Process<TElement>(IObservable<TElement>, Func<TElement, TSource>, string)

Writes all elements of an observable sequence to the specified file.

protected IObservable<TElement> Process<TElement>(IObservable<TElement> source, Func<TElement, TSource> selector, string fileName)

Parameters

source IObservable<TElement>

The sequence of elements to write to the file.

selector Func<TElement, TSource>

The transform function used to convert each element of the sequence into the type of inputs accepted by the file writer.

fileName string

The name of the file on which to write the elements.

Returns

IObservable<TElement>

An observable sequence that is identical to the source sequence but where there is an additional side effect of writing the elements to a file.

Type Parameters

TElement

The type of the elements in the source sequence.

Exceptions

ArgumentNullException

Write(TWriter, TSource)

When overridden in a derived class, writes a new element into the specified writer.

protected abstract void Write(TWriter writer, TSource input)

Parameters

writer TWriter

The writer that is used to push elements into the file.

input TSource

The input element that should be pushed into the file.