Class FlowStepConfig<TState>
- Namespace
- SharpConsoleUI.Flows
- Assembly
- SharpConsoleUI.dll
Fluent per-step customization sub-builder for a content+buttons wizard step (see
Step(Func<TState, IFlowStepContent<object?>>)). Lets the
app override the affirmative button label/enable predicate and supply click callbacks whose
returned FlowVerdict drives the loop. Its members return this sub-builder; the
parent wizard's builder methods (Step, WithStepIndicator, WithTitle,
Seed, Run) are forwarded so chaining the next step or running flows naturally.
public sealed class FlowStepConfig<TState> where TState : new()
Type Parameters
TStateThe mutable wizard state type.
- Inheritance
-
FlowStepConfig<TState>
- Inherited Members
- Extension Methods
Methods
BackLabel(string)
Relabels the Back button.
public FlowStepConfig<TState> BackLabel(string label)
Parameters
labelstringThe new label.
Returns
- FlowStepConfig<TState>
This sub-builder, for chaining.
CanGoNext(Func<FlowContext, TState, bool>)
Sets the predicate controlling the affirmative (Next/Finish) button's enabled state. It is re-evaluated live on the content's StateChanged via the chrome's RefreshButtons delegate.
public FlowStepConfig<TState> CanGoNext(Func<FlowContext, TState, bool> predicate)
Parameters
predicateFunc<FlowContext, TState, bool>Returns
trueto enable the affirmative button.
Returns
- FlowStepConfig<TState>
This sub-builder, for chaining.
NextLabel(string)
Relabels the affirmative (Next/Finish) button.
public FlowStepConfig<TState> NextLabel(string label)
Parameters
labelstringThe new label.
Returns
- FlowStepConfig<TState>
This sub-builder, for chaining.
OnBack(Func<FlowContext, TState, Task<FlowVerdict>>)
Callback invoked when the Back button is clicked; its return is the verdict (default Back).
public FlowStepConfig<TState> OnBack(Func<FlowContext, TState, Task<FlowVerdict>> callback)
Parameters
callbackFunc<FlowContext, TState, Task<FlowVerdict>>The click callback returning the navigation verdict.
Returns
- FlowStepConfig<TState>
This sub-builder, for chaining.
OnCancel(Func<FlowContext, TState, Task<FlowVerdict>>)
Callback invoked when the Cancel button is clicked; its return is the verdict (default Cancel).
public FlowStepConfig<TState> OnCancel(Func<FlowContext, TState, Task<FlowVerdict>> callback)
Parameters
callbackFunc<FlowContext, TState, Task<FlowVerdict>>The click callback returning the navigation verdict.
Returns
- FlowStepConfig<TState>
This sub-builder, for chaining.
OnNext(Func<FlowContext, TState, Task<FlowVerdict>>)
Callback invoked when the affirmative (Next/Finish) button is clicked; its return is the verdict.
public FlowStepConfig<TState> OnNext(Func<FlowContext, TState, Task<FlowVerdict>> callback)
Parameters
callbackFunc<FlowContext, TState, Task<FlowVerdict>>The click callback returning the navigation verdict.
Returns
- FlowStepConfig<TState>
This sub-builder, for chaining.
Run(ConsoleWindowSystem, Window?, IFlowHost?, CancellationToken)
Runs the wizard: presents each step in order through host (or a default
ModalWindowHost), honouring Next/Back/Cancel/Finish/Stay, the Back commit-barrier,
and the optional step indicator. A wholly-blocked Back (at step 0 or pinned by the commit
barrier) re-presents the current step unchanged (Stay semantics) — the wizard and its
state are preserved and the loop continues. Cancellation surfaces as
Cancelled; any other exception is logged and surfaced as
Faulted.
public Task<FlowResult<TState>> Run(ConsoleWindowSystem ws, Window? parent, IFlowHost? host = null, CancellationToken cancellationToken = default)
Parameters
wsConsoleWindowSystemThe window system the wizard presents into.
parentWindowOptional parent window for the default modal host; ignored when
hostis supplied.hostIFlowHostOptional presentation host. When
nulla ModalWindowHost is used.cancellationTokenCancellationTokenOptional external cancellation. When it is cancelled the wizard's own token trips (via a linked source), so the in-flight step resolves Cancel and the loop surfaces Cancelled. Used, for example, by FlowControl to cancel a running inline wizard when its control is removed from the visual tree mid-flow.
Returns
- Task<FlowResult<TState>>
The wizard outcome carrying the final state on completion.
Seed(TState)
Sets the initial wizard state (otherwise a default-constructed instance is used).
public FlowWizardBuilder<TState> Seed(TState state)
Parameters
stateTStateThe seed state.
Returns
- FlowWizardBuilder<TState>
This builder, for chaining.
Step(Func<FlowContext, TState, Task<FlowVerdict>>)
Adds a code-driven step: the body runs with the shared context and state and returns a FlowVerdict that drives the loop.
public FlowWizardBuilder<TState> Step(Func<FlowContext, TState, Task<FlowVerdict>> step)
Parameters
stepFunc<FlowContext, TState, Task<FlowVerdict>>The step body returning a navigation verdict.
Returns
- FlowWizardBuilder<TState>
This builder, for chaining.
Step(Func<TState, IFlowStepContent<object?>>)
Adds a content + standardized buttons step: the factory builds the step content (which
writes its result into TState), and the wizard renders the
context-aware button row, presents the content, and maps the chosen button to a verdict.
Returns a FlowStepConfig<TState> sub-builder for fluent per-step overrides
(.OnNext, .OnBack, .OnCancel, .CanGoNext, .NextLabel,
.BackLabel); its members return the same sub-builder, and adding the next step continues
from the parent wizard builder.
public FlowStepConfig<TState> Step(Func<TState, IFlowStepContent<object?>> contentFactory)
Parameters
contentFactoryFunc<TState, IFlowStepContent<object>>Builds the step content for the current state. The content's typed value is ignored; callbacks read
TState.
Returns
- FlowStepConfig<TState>
A FlowStepConfig<TState> for fluent customization of this step.
WithStepIndicator()
Enables the step indicator: each step's FlowChrome carries a
(Index, Count) tuple so the host can render e.g. "(2/3)".
public FlowWizardBuilder<TState> WithStepIndicator()
Returns
- FlowWizardBuilder<TState>
This builder, for chaining.
WithStepTitle(string)
Sets the host frame title for this step.
public FlowStepConfig<TState> WithStepTitle(string title)
Parameters
titlestringThe title.
Returns
- FlowStepConfig<TState>
This sub-builder, for chaining.
WithTitle(string)
Sets a default title used for content+buttons steps that do not override it. Code-driven steps title their own host frames via the FlowContext verbs.
public FlowWizardBuilder<TState> WithTitle(string title)
Parameters
titlestringThe default step title.
Returns
- FlowWizardBuilder<TState>
This builder, for chaining.