Table of Contents

Class PipelineBuilderDeferredExtensions

Namespace
Excalibur.Dispatch.Configuration
Assembly
Excalibur.Dispatch.dll

Registers middleware with explicit metadata without activating a composition-time probe.

public static class PipelineBuilderDeferredExtensions
Inheritance
PipelineBuilderDeferredExtensions
Inherited Members

Methods

UseDeferred<TMiddleware>(IPipelineBuilder, Func<IServiceProvider, TMiddleware>, DispatchMiddlewareStage?, MessageKinds)

Adds required middleware that is activated only when an applicable message executes.

public static IPipelineBuilder UseDeferred<TMiddleware>(this IPipelineBuilder builder, Func<IServiceProvider, TMiddleware> middlewareFactory, DispatchMiddlewareStage? stage, MessageKinds messageKinds) where TMiddleware : class, IDispatchMiddleware

Parameters

builder IPipelineBuilder

The pipeline builder.

middlewareFactory Func<IServiceProvider, TMiddleware>

Resolves DI-owned middleware from the dispatch service provider.

stage DispatchMiddlewareStage?

The authoritative pipeline stage.

messageKinds MessageKinds

The authoritative applicable message kinds.

Returns

IPipelineBuilder

The builder for chaining.

Type Parameters

TMiddleware

The exact concrete middleware type returned by the factory.

Remarks

Use this path for async-only disposable middleware or dependencies. The stock pipeline builder supplies a dispatch scope and awaits disposal of scopes it owns. Borrowed scopes remain caller-owned. The factory must return the exact declared type; null or a derived type fails before invocation. Factory activation is validated at dispatch time, not startup. Custom pipeline builders must supply a valid RequestServices. Instances created outside DI remain the factory owner's disposal responsibility. Stage and kinds supplied here override instance metadata. The stock builder intersects its message-kind filter with these explicit kinds; it never widens them.