Class StreamSink<TSource, TWriter>
Provides a base class for sinks that write the elements from the input sequence into a named stream (e.g. a named pipe).
public abstract class StreamSink<TSource, TWriter> : StreamSink where TWriter : class, IDisposable
Type Parameters
TSourceThe type of the elements in the source sequence.
TWriterThe type of stream writer that should be used to write the elements.
- Inheritance
-
StreamSink<TSource, TWriter>
- Derived
- Inherited Members
Methods
CreateWriter(Stream)
When overridden in a derived class, creates the object that will be responsible for writing the input elements to the specified Stream.
protected abstract TWriter CreateWriter(Stream stream)
Parameters
streamStreamThe stream on which the elements should be written.
Returns
- TWriter
The object that will be used to write elements into the stream.
Process(IObservable<TSource>)
Writes all elements of an observable sequence to the specified stream.
public virtual IObservable<TSource> Process(IObservable<TSource> source)
Parameters
sourceIObservable<TSource>The sequence of elements to write.
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 stream.
Process<TElement>(IObservable<TElement>, Func<TElement, TSource>)
Writes all elements of an observable sequence to a stream.
protected IObservable<TElement> Process<TElement>(IObservable<TElement> source, Func<TElement, TSource> selector)
Parameters
sourceIObservable<TElement>The sequence of elements to write.
selectorFunc<TElement, TSource>The transform function used to convert each element of the sequence into the type of inputs accepted by the stream 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 stream.
Type Parameters
TElementThe type of the elements in the source sequence.
Exceptions
- ArgumentNullException
- InvalidOperationException
A valid path must be specified.
Process<TElement>(IObservable<TElement>, Func<TElement, TSource>, string)
Writes all elements of an observable sequence into the specified stream.
protected IObservable<TElement> Process<TElement>(IObservable<TElement> source, Func<TElement, TSource> selector, string path)
Parameters
sourceIObservable<TElement>The sequence of elements to write.
selectorFunc<TElement, TSource>The transform function used to convert each element of the sequence into the type of inputs accepted by the stream writer.
pathstringThe identifier of the stream 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 the named stream.
Type Parameters
TElementThe type of the elements in the source sequence.
Exceptions
- ArgumentNullException
- InvalidOperationException
A valid path must be specified.
Write(TWriter, TSource)
When overridden in a derived class, writes a new element using the specified writer.
protected abstract void Write(TWriter writer, TSource input)
Parameters
writerTWriterThe writer used to push elements into the stream.
inputTSourceThe input element that should be pushed into the stream.