ข้ามไปยังเนื้อหา

Class BehaviorDispatcher

เนื้อหานี้ยังไม่ได้แปลเป็นภาษาไทย แสดงเป็นภาษาอังกฤษแทน

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

Resolves behavior instances from the service provider and dispatches calls to the appropriate by behavior identifier. The dispatch table is built once at construction time from a frozen dictionary for O(1) lock-free lookup on every call.

public sealed class BehaviorDispatcher

objectBehaviorDispatcher

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

BehaviorDispatcher(IBehaviorCatalog, IBehaviorTypeRegistry, IServiceProvider)

Section titled “ BehaviorDispatcher(IBehaviorCatalog, IBehaviorTypeRegistry, IServiceProvider)”

Initializes the dispatcher by building its frozen dispatch table from the catalog and type registry. Only behaviors that appear in both the catalog and the type registry are dispatchable.

public BehaviorDispatcher(IBehaviorCatalog catalog, IBehaviorTypeRegistry typeRegistry, IServiceProvider services)

catalog IBehaviorCatalog

The behavior catalog that exposes topology descriptors.

typeRegistry IBehaviorTypeRegistry

The registry that maps behavior identifiers to concrete types.

services IServiceProvider

The service provider used to resolve behavior instances at dispatch time.

DispatchAsync(string, object, IBehaviorContext, CancellationToken)

Section titled “ DispatchAsync(string, object, IBehaviorContext, CancellationToken)”

Dispatches a call to the behavior identified by behaviorId. The behavior instance is resolved from the service provider on every call.

public Task<object?> DispatchAsync(string behaviorId, object input, IBehaviorContext context, CancellationToken ct = default)

behaviorId string

The stable identifier of the behavior to invoke.

input object

The input message object.

context IBehaviorContext

The behavior execution context.

ct CancellationToken

A token that cancels the dispatch.

Task<object?>

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

BehaviorNotFoundException

Thrown when behaviorId is not present in the dispatch table.