Skip to content

Class BehaviorExecutionSlot

Namespace: Cephalon.Behaviors.Services
Assembly: Cephalon.Behaviors.dll

A compiled, type-safe invocation delegate for a concrete implementation. Slots are created once at dispatcher construction time and reused for every dispatch call.

public sealed class BehaviorExecutionSlot

objectBehaviorExecutionSlot

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Creates a for a behavior whose generic type arguments are known at compile time.

public static BehaviorExecutionSlot For<TBehavior, TIn, TOut>() where TBehavior : IAppBehavior<TIn, TOut> where TIn : notnull

BehaviorExecutionSlot

A compiled execution slot for the behavior.

TBehavior

The concrete behavior type.

TIn

The input message type.

TOut

The output message type.

Creates a for a behavior type discovered at runtime via reflection. The IAppBehavior<TIn, TOut> interface is located on behaviorType and the generic factory is invoked via reflection once to build a closed delegate.

public static BehaviorExecutionSlot ForType(Type behaviorType)

behaviorType Type

The concrete behavior implementation type.

BehaviorExecutionSlot

A compiled execution slot for the behavior.

InvalidOperationException

Thrown when behaviorType does not implement IAppBehavior<TIn, TOut>.

InvokeAsync(object, object, IBehaviorContext, CancellationToken)

Section titled “ InvokeAsync(object, object, IBehaviorContext, CancellationToken)”

Invokes the compiled behavior delegate.

public Task<object?> InvokeAsync(object behavior, object input, IBehaviorContext context, CancellationToken ct = default)

behavior object

The resolved behavior instance.

input object

The input message object.

context IBehaviorContext

The behavior execution context.

ct CancellationToken

A token that cancels the invocation.

Task<object?>

A task that resolves to the behavior output, boxed as .