Table of Contents

Struct PolicyBuilder<T1, T2>

Namespace
Executables.Policies
Assembly
executables.dll

Builds a composed policy pipeline.

public readonly struct PolicyBuilder<T1, T2>

Type Parameters

T1

Input type of the target executable.

T2

Output type of the target executable.

Inherited Members

Remarks

Policies are invoked in reverse order of addition: the last added policy executes first.

Constructors

PolicyBuilder()

Builds a composed policy pipeline.

public PolicyBuilder()

Remarks

Policies are invoked in reverse order of addition: the last added policy executes first.

Methods

Add(Policy<T1, T2>)

Adds a policy to the builder pipeline.

public PolicyBuilder<T1, T2> Add(Policy<T1, T2> policy)

Parameters

policy Policy<T1, T2>

Policy to add.

Returns

PolicyBuilder<T1, T2>

Current builder instance.

Create(Func<T1, IExecutor<T1, T2>, T2>)

Adds a policy created from a delegate.

public PolicyBuilder<T1, T2> Create(Func<T1, IExecutor<T1, T2>, T2> policy)

Parameters

policy Func<T1, IExecutor<T1, T2>, T2>

Delegate implementing policy behavior.

Returns

PolicyBuilder<T1, T2>

Current builder instance.

Fallback<TEx>(Func<T1, TEx, T2>)

Creates a fallback policy from a delegate.

public PolicyBuilder<T1, T2> Fallback<TEx>(Func<T1, TEx, T2> fallback) where TEx : Exception

Parameters

fallback Func<T1, TEx, T2>

Delegate that converts input and exception into a fallback result.

Returns

PolicyBuilder<T1, T2>

Current builder instance.

Type Parameters

TEx

Handled exception type.

Guard(Guard)

Adds a policy that blocks invocation when the guard denies access.

public PolicyBuilder<T1, T2> Guard(Guard guard)

Parameters

guard Guard

Guard that controls whether invocation is allowed.

Returns

PolicyBuilder<T1, T2>

Current builder instance.

PreventReentrance()

Adds a policy that rejects reentrant execution.

public PolicyBuilder<T1, T2> PreventReentrance()

Returns

PolicyBuilder<T1, T2>

Current builder instance.

Validate(Validator<T1>, Validator<T2>)

Adds a policy that validates input before invocation and output after invocation.

public PolicyBuilder<T1, T2> Validate(Validator<T1> inputValidator, Validator<T2> outputValidator)

Parameters

inputValidator Validator<T1>

Validator for invocation input.

outputValidator Validator<T2>

Validator for invocation result.

Returns

PolicyBuilder<T1, T2>

Current builder instance.