Class Flow
- Namespace
- SharpConsoleUI.Flows
- Assembly
- SharpConsoleUI.dll
Entry points for running composable flows. Run<T>(ConsoleWindowSystem, Window?, Func<FlowContext, Task<T>>, IFlowHost?, CancellationToken) hosts an imperative flow body (handed a FlowContext) and surfaces its terminal state as a FlowResult<T>: completed with a value, cancelled, or faulted. The declarative wizard loop is added to this same class (Tier B) in a separate partial.
public static class Flow
- Inheritance
-
Flow
- Inherited Members
Methods
Run(ConsoleWindowSystem, Window?, Func<FlowContext, Task>, IFlowHost?, CancellationToken)
Runs an imperative flow that produces no payload. The returned FlowResult<T> carries
bool with Value set to true on completion (callers
typically inspect only Completed / Cancelled).
public static Task<FlowResult<bool>> Run(ConsoleWindowSystem ws, Window? parent, Func<FlowContext, Task> body, IFlowHost? host = null, CancellationToken cancellationToken = default)
Parameters
wsConsoleWindowSystemThe window system the flow presents into.
parentWindowOptional parent window for the default modal host; ignored when
hostis supplied.bodyFunc<FlowContext, Task>The flow body; receives a FlowContext.
hostIFlowHostOptional presentation host. When
nulla ModalWindowHost is used.cancellationTokenCancellationTokenOptional external cancellation; when cancelled the flow's own token trips (see the typed Run<T>(ConsoleWindowSystem, Window?, Func<FlowContext, Task<T>>, IFlowHost?, CancellationToken)).
Returns
- Task<FlowResult<bool>>
A FlowResult<T> of
bool, withValue == trueon completion.
Run<T>(ConsoleWindowSystem, Window?, Func<FlowContext, Task<T>>, IFlowHost?, CancellationToken)
Runs an imperative flow that produces a typed value.
public static Task<FlowResult<T>> Run<T>(ConsoleWindowSystem ws, Window? parent, Func<FlowContext, Task<T>> body, IFlowHost? host = null, CancellationToken cancellationToken = default)
Parameters
wsConsoleWindowSystemThe window system the flow presents into.
parentWindowOptional parent window for the default modal host; ignored when
hostis supplied.bodyFunc<FlowContext, Task<T>>The flow body; receives a FlowContext and returns the flow's value.
hostIFlowHostOptional presentation host. When
nulla ModalWindowHost is used.cancellationTokenCancellationTokenOptional external cancellation. When it is cancelled the flow's own token trips (via a linked source), so the in-flight step resolves Cancel and any subsequent
awaitin the body observes OperationCanceledException → Cancelled. Used, for example, by FlowControl to cancel a running inline flow when its control is removed from the visual tree mid-flow.
Returns
- Task<FlowResult<T>>
A FlowResult<T>: completed with the body's value, cancelled when the body throws OperationCanceledException, or faulted for any other exception.
Type Parameters
TThe value type produced by a successful flow.
Wizard<TState>()
Begins building a declarative wizard (Tier B) over a mutable TState.
Add ordered steps with Step(Func<FlowContext, TState, Task<FlowVerdict>>)
(code-driven) or Step(Func<TState, IFlowStepContent<object?>>)
(content + standardized buttons), then run with
Run(ConsoleWindowSystem, Window?, IFlowHost?, CancellationToken). The
wizard owns the navigation loop (Next/Back/Cancel/Finish/Stay), the step indicator, and the
Back commit-barrier; the shared state flows through every step.
public static FlowWizardBuilder<TState> Wizard<TState>() where TState : new()
Returns
- FlowWizardBuilder<TState>
A new FlowWizardBuilder<TState>.
Type Parameters
TStateThe mutable wizard state type; default-constructed unless seeded.