Table of Contents

Class BasePropagatorBlock<TInput, TOutput>

Namespace
DotnetKit.DataflowBuilder.Abstractions
Assembly
DotnetKit.DataflowBuilder.dll

Base class for custom propagator blocks that combine an internal target block and source block into an encapsulated IPropagatorBlock<TInput, TOutput>.

public abstract class BasePropagatorBlock<TInput, TOutput> : IPropagatorBlock<TInput, TOutput>, ITargetBlock<TInput>, ISourceBlock<TOutput>, IDataflowBlock

Type Parameters

TInput

The type of items accepted by the target end of the block.

TOutput

The type of items produced by the source end of the block.

Inheritance
BasePropagatorBlock<TInput, TOutput>
Implements
IPropagatorBlock<TInput, TOutput>
ITargetBlock<TInput>
ISourceBlock<TOutput>
Derived
Inherited Members

Properties

Completion

Gets a Task that represents the asynchronous operation and completion of the dataflow block.

public virtual Task Completion { get; }

Property Value

Task

Pipeline

Gets the encapsulated propagator block combining Target and Source.

public IPropagatorBlock<TInput, TOutput> Pipeline { get; }

Property Value

IPropagatorBlock<TInput, TOutput>

Source

Gets the inner source block responsible for dispatching outgoing messages.

public abstract ISourceBlock<TOutput> Source { get; }

Property Value

ISourceBlock<TOutput>

Target

Gets the inner target block responsible for receiving incoming messages.

public abstract ITargetBlock<TInput> Target { get; }

Property Value

ITargetBlock<TInput>

Methods

Complete()

Signals the target block that no more data will be provided, and propagates completion to the source block.

public virtual void Complete()

ConsumeMessage(DataflowMessageHeader, ITargetBlock<TOutput>, out bool)

Consumes a previously reserved message from the source block.

public virtual TOutput? ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)

Parameters

messageHeader DataflowMessageHeader

The header of the message being consumed.

target ITargetBlock<TOutput>

The target block consuming the message.

messageConsumed bool

Set to true if the message was successfully consumed; otherwise, false.

Returns

TOutput

The consumed message value, or default if the message could not be consumed.

Fault(Exception)

Causes the encapsulated dataflow block to complete in a faulted state with the specified exception.

public virtual void Fault(Exception exception)

Parameters

exception Exception

The exception that caused the fault.

LinkTo(ITargetBlock<TOutput>, DataflowLinkOptions)

Links this source block to the specified target block with the given link options.

public virtual IDisposable LinkTo(ITargetBlock<TOutput> target, DataflowLinkOptions linkOptions)

Parameters

target ITargetBlock<TOutput>

The target block to link to.

linkOptions DataflowLinkOptions

Options defining the link behavior, such as completion propagation.

Returns

IDisposable

An IDisposable that can be used to unlink the source and target blocks.

OfferMessage(DataflowMessageHeader, TInput, ISourceBlock<TInput>?, bool)

Offers a message to the target block and yields status regarding its consumption or rejection.

public virtual DataflowMessageStatus OfferMessage(DataflowMessageHeader messageHeader, TInput messageValue, ISourceBlock<TInput>? source, bool consumeToAccept)

Parameters

messageHeader DataflowMessageHeader

The header identifying the offered message.

messageValue TInput

The message payload being offered.

source ISourceBlock<TInput>

The source block offering the message, or null.

consumeToAccept bool

Whether the target must consume the message to accept it.

Returns

DataflowMessageStatus

The acceptance status of the offered message.

ReleaseReservation(DataflowMessageHeader, ITargetBlock<TOutput>)

Releases a previous message reservation on the source block.

public virtual void ReleaseReservation(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target)

Parameters

messageHeader DataflowMessageHeader

The header of the message reservation being released.

target ITargetBlock<TOutput>

The target block that held the reservation.

ReserveMessage(DataflowMessageHeader, ITargetBlock<TOutput>)

Reserves a message previously offered by the source block.

public virtual bool ReserveMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target)

Parameters

messageHeader DataflowMessageHeader

The header of the message being reserved.

target ITargetBlock<TOutput>

The target block attempting to reserve the message.

Returns

bool

true if the message was successfully reserved; otherwise, false.