MiddlewareContext(Func<InvocationContext, Task>, CancellationToken, MiddlewareItems?) Constructor

Definition

Assembly CliInvoke.Core.dll

Initializes a new instance of the MiddlewareContext class.

public MiddlewareContext(Func<InvocationContext, Task> next, CancellationToken cancellationToken, MiddlewareItems? items = null)

Parameters

next
Func<InvocationContext, Task>

The delegate that continues the chain (the terminal pipeline for a freshly created context). The chain walker re-points this at each step's forward delegate while that step executes and restores it when the step returns, so during a middleware's execution it always identifies the delegate that invokes the next middleware or the terminal.

cancellationToken
CancellationToken

The cancellation token for the chain run. The same token is shared by every middleware in the chain.

items
MiddlewareItems

Optional pre-seeded items. When provided, the context shares this instance so values injected before the chain runs (e.g. a logger) are visible to every middleware. When omitted, a fresh MiddlewareItems is created.