Table of Contents

Class AsyncActionStrategy<TIn>.Builder

Namespace
PatternKit.Behavioral.Strategy
Assembly
PatternKit.Core.dll

Fluent builder for composing AsyncActionStrategy<TIn> branches.

public sealed class AsyncActionStrategy<TIn>.Builder
Inheritance
AsyncActionStrategy<TIn>.Builder
Inherited Members

Remarks

Use When(Predicate) to add predicate/handler branches and Default(Handler) to set an optional fallback handler.

Methods

Build()

Finalizes the configuration and creates an immutable AsyncActionStrategy<TIn>.

public AsyncActionStrategy<TIn> Build()

Returns

AsyncActionStrategy<TIn>

An immutable strategy instance.

Default(Handler)

Sets the default (fallback) handler used when no predicates match.

public AsyncActionStrategy<TIn>.Builder Default(AsyncActionStrategy<TIn>.Handler handler)

Parameters

handler AsyncActionStrategy<TIn>.Handler

The asynchronous default handler.

Returns

AsyncActionStrategy<TIn>.Builder

The current AsyncActionStrategy<TIn>.Builder for chaining.

Default(Action<TIn>)

Sets the default (fallback) handler using a synchronous delegate.

public AsyncActionStrategy<TIn>.Builder Default(Action<TIn> syncHandler)

Parameters

syncHandler Action<TIn>

Synchronous default handler; wrapped as async.

Returns

AsyncActionStrategy<TIn>.Builder

The current AsyncActionStrategy<TIn>.Builder for chaining.

When(Predicate)

Adds a new branch that will be considered during execution.

public AsyncActionStrategy<TIn>.Builder.WhenBuilder When(AsyncActionStrategy<TIn>.Predicate pred)

Parameters

pred AsyncActionStrategy<TIn>.Predicate

An asynchronous predicate for the branch.

Returns

AsyncActionStrategy<TIn>.Builder.WhenBuilder

A AsyncActionStrategy<TIn>.Builder.WhenBuilder that allows specifying the corresponding handler via Then(Handler).

When(Func<TIn, bool>)

Adds a branch using a synchronous predicate (no CancellationToken).

public AsyncActionStrategy<TIn>.Builder.WhenBuilder When(Func<TIn, bool> syncPred)

Parameters

syncPred Func<TIn, bool>

Synchronous predicate; wrapped as an async predicate.

Returns

AsyncActionStrategy<TIn>.Builder.WhenBuilder

A AsyncActionStrategy<TIn>.Builder.WhenBuilder to specify the handler.

When(Func<TIn, CancellationToken, bool>)

Adds a branch using a synchronous predicate that accepts a CancellationToken.

public AsyncActionStrategy<TIn>.Builder.WhenBuilder When(Func<TIn, CancellationToken, bool> syncPredWithCt)

Parameters

syncPredWithCt Func<TIn, CancellationToken, bool>

Synchronous predicate receiving a token; wrapped as async.

Returns

AsyncActionStrategy<TIn>.Builder.WhenBuilder

A AsyncActionStrategy<TIn>.Builder.WhenBuilder to specify the handler.