Table of Contents

Class Command

Namespace
The.Web.Pages
Assembly
Instagile.Web.Client.dll
public class Command
Inheritance
Command
Derived
Inherited Members

Constructors

Command(Func<string>, Action)

public Command(Func<string> getLabel, Action execute)

Parameters

getLabel Func<string>
execute Action

Command(Func<string>, Action, Func<bool>?, Func<IServices, bool>?, bool)

[Obsolete("Use one of the two-argument constructors along with builder methods.")]
public Command(Func<string> getLabel, Action execute, Func<bool>? canExecute = null, Func<IServices, bool>? isVisible = null, bool primary = false)

Parameters

getLabel Func<string>
execute Action
canExecute Func<bool>
isVisible Func<IServices, bool>
primary bool

Command(Func<string>, Func<Task>)

public Command(Func<string> getLabel, Func<Task> execute)

Parameters

getLabel Func<string>
execute Func<Task>

Command(Func<string>, Func<Task>, Func<bool>?, Func<IServices, bool>?, bool)

[Obsolete("Use one of the two-argument constructors along with builder methods.")]
public Command(Func<string> getLabel, Func<Task> execute, Func<bool>? canExecute = null, Func<IServices, bool>? isVisible = null, bool primary = false)

Parameters

getLabel Func<string>
execute Func<Task>
canExecute Func<bool>
isVisible Func<IServices, bool>
primary bool

Command(Func<string>, Func<Task>, Func<Task<bool>>, Func<IServices, Task<bool>>?, bool)

[Obsolete("Use one of the two-argument constructors along with builder methods.")]
public Command(Func<string> getLabel, Func<Task> execute, Func<Task<bool>> canExecute, Func<IServices, Task<bool>>? isVisible = null, bool primary = false)

Parameters

getLabel Func<string>
execute Func<Task>
canExecute Func<Task<bool>>
isVisible Func<IServices, Task<bool>>
primary bool

Command(string, Action)

public Command(string label, Action execute)

Parameters

label string
execute Action

Command(string, Action, Func<bool>?, Func<IServices, bool>?, bool)

[Obsolete("Use one of the two-argument constructors along with builder methods.")]
public Command(string label, Action execute, Func<bool>? canExecute = null, Func<IServices, bool>? isVisible = null, bool primary = false)

Parameters

label string
execute Action
canExecute Func<bool>
isVisible Func<IServices, bool>
primary bool

Command(string, Func<Task>)

public Command(string label, Func<Task> execute)

Parameters

label string
execute Func<Task>

Command(string, Func<Task>, Func<bool>?, Func<IServices, bool>?, bool)

[Obsolete("Use one of the two-argument constructors along with builder methods.")]
public Command(string label, Func<Task> execute, Func<bool>? canExecute = null, Func<IServices, bool>? isVisible = null, bool primary = false)

Parameters

label string
execute Func<Task>
canExecute Func<bool>
isVisible Func<IServices, bool>
primary bool

Command(string, Func<Task>, Func<Task<bool>>, Func<IServices, Task<bool>>?, bool)

[Obsolete("Use one of the two-argument constructors along with builder methods.")]
public Command(string label, Func<Task> execute, Func<Task<bool>> canExecute, Func<IServices, Task<bool>>? isVisible = null, bool primary = false)

Parameters

label string
execute Func<Task>
canExecute Func<Task<bool>>
isVisible Func<IServices, Task<bool>>
primary bool

Properties

CanAlwaysExecute

public bool CanAlwaysExecute { get; }

Property Value

bool

Icon

The command's optional icon name.

public string? Icon { get; }

Property Value

string

IsAlwaysVisible

public bool IsAlwaysVisible { get; }

Property Value

bool

Key

The command's stable identity for registration replacement, de-duplication and render keying: the label captured the first time it is read, so it stays fixed even if the label later changes.

public string Key { get; }

Property Value

string

Label

The command's variable display identity.

public string Label { get; }

Property Value

string

Level

The colour scheme this command is presented with when rendered as a button, or null to use the button's default colours.

public MessageLevel? Level { get; }

Property Value

MessageLevel?

Shortcut

Activates this command's presenting control (if it is visible and enabled).

public KeyboardShortcut? Shortcut { get; }

Property Value

KeyboardShortcut

Tier

The display-hierarchy level this command is presented at when rendered as a button.

public ButtonTier Tier { get; }

Property Value

ButtonTier

Methods

CanExecute()

public Task<bool> CanExecute()

Returns

Task<bool>

Enable(Func<bool>)

public Command Enable(Func<bool> canExecute)

Parameters

canExecute Func<bool>

Returns

Command

Enable(Func<Task<bool>>)

public Command Enable(Func<Task<bool>> canExecute)

Parameters

canExecute Func<Task<bool>>

Returns

Command

ExecuteAsync(IServiceProvider, Action<Exception>)

Runs the command's execute delegate directly, bypassing ExecuteAsync(Command, IServiceProvider) and with it the context's serial-execution guarantee, notification clearing and The.Web.Pages.Command.Requirement gating; a caller takes on responsibility for those concerns itself.

public Task ExecuteAsync(IServiceProvider provider, Action<Exception> onError)

Parameters

provider IServiceProvider
onError Action<Exception>

Returns

Task

IsVisible(IServices)

public Task<bool> IsVisible(IServices services)

Parameters

services IServices

Returns

Task<bool>

Rename(Func<string>)

public Command Rename(Func<string> getLabel)

Parameters

getLabel Func<string>

Returns

Command

Rename(string)

public Command Rename(string label)

Parameters

label string

Returns

Command

Show(Func<IServices, bool>)

public Command Show(Func<IServices, bool> isVisible)

Parameters

isVisible Func<IServices, bool>

Returns

Command

Show(Func<IServices, Task<bool>>)

public Command Show(Func<IServices, Task<bool>> isVisible)

Parameters

isVisible Func<IServices, Task<bool>>

Returns

Command

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Validate(ValidationIntent?, MessageLevel)

[Obsolete("Use WithValidation()")]
public Command Validate(ValidationIntent? intent = null, MessageLevel blockAt = MessageLevel.Error)

Parameters

intent ValidationIntent?
blockAt MessageLevel

Returns

Command

VisibleWhen(Func<IServices, bool>)

[Obsolete("Use Show()")]
public Command VisibleWhen(Func<IServices, bool> isVisible)

Parameters

isVisible Func<IServices, bool>

Returns

Command

VisibleWhen(Func<IServices, Task<bool>>)

[Obsolete("Use Show()")]
public Command VisibleWhen(Func<IServices, Task<bool>> isVisible)

Parameters

isVisible Func<IServices, Task<bool>>

Returns

Command

WithIcon(string)

Names an icon from the Lucide set to be displayed alongside the command's label.

public Command WithIcon(string icon)

Parameters

icon string

Returns

Command

WithLevel(MessageLevel?)

Declares the colour scheme this command is presented with when rendered as a button; null uses the button's default colours.

public Command WithLevel(MessageLevel? level)

Parameters

level MessageLevel?

Returns

Command

WithModal(string, string, RenderFragment)

Declares the routed modal this command opens with OpenModal(); CommandPanel registers it while the command is visible.

public Command WithModal(string route, string title, RenderFragment content)

Parameters

route string
title string
content RenderFragment

Returns

Command

WithModal(string, string, RenderFragment<IReadOnlyDictionary<string, object>>)

Declares the routed modal this command opens, with content receiving the route values it was opened with.

public Command WithModal(string route, string title, RenderFragment<IReadOnlyDictionary<string, object>> content)

Parameters

route string
title string
content RenderFragment<IReadOnlyDictionary<string, object>>

Returns

Command

WithPrimary(bool)

[Obsolete("Use WithTier()")]
public Command WithPrimary(bool primary)

Parameters

primary bool

Returns

Command

WithShortcut(char, ShortcutModifiers)

Declares the shortcut that activates this command's presenting control (if it is visible and enabled).

public Command WithShortcut(char key, ShortcutModifiers modifiers)

Parameters

key char

A single-character KeyboardEvent.key value, lowercased.

modifiers ShortcutModifiers

Must include CmdOrCtrl, Ctrl or Alt.

Returns

Command

WithShortcut(string, ShortcutModifiers)

Declares the shortcut that activates this command's presenting control (if it is visible and enabled).

public Command WithShortcut(string key, ShortcutModifiers modifiers)

Parameters

key string

A KeyboardEvent.key value, such as "s", "F5" or "ArrowLeft".

modifiers ShortcutModifiers

Must include CmdOrCtrl, Ctrl or Alt.

Returns

Command

WithShortcut(KeyboardShortcut)

Declares the shortcut that activates this command's presenting control (if it is visible and enabled).

public Command WithShortcut(KeyboardShortcut shortcut)

Parameters

shortcut KeyboardShortcut

Returns

Command

WithTier(ButtonTier)

Declares the display-hierarchy level of this command when presented as a button.

public Command WithTier(ButtonTier tier)

Parameters

tier ButtonTier

Returns

Command

WithValidation(ValidationIntent?, MessageLevel)

Declares the validation this command runs before executing.

public Command WithValidation(ValidationIntent? intent = null, MessageLevel blockAt = MessageLevel.Error)

Parameters

intent ValidationIntent?

Passed to validation rules. Defaults to Save.

blockAt MessageLevel

Prevents execution at this level of findings.

Returns

Command

Wrap(Func<Func<Task>, Func<Task>>)

public Command Wrap(Func<Func<Task>, Func<Task>> wrapExecute)

Parameters

wrapExecute Func<Func<Task>, Func<Task>>

Returns

Command

Wrap<T>(Func<Func<Task>, T, Func<Task>>)

public Command Wrap<T>(Func<Func<Task>, T, Func<Task>> wrapExecute) where T : notnull

Parameters

wrapExecute Func<Func<Task>, T, Func<Task>>

Returns

Command

Type Parameters

T

Wrap<T1, T2>(Func<Func<Task>, T1, T2, Func<Task>>)

public Command Wrap<T1, T2>(Func<Func<Task>, T1, T2, Func<Task>> wrapExecute) where T1 : notnull where T2 : notnull

Parameters

wrapExecute Func<Func<Task>, T1, T2, Func<Task>>

Returns

Command

Type Parameters

T1
T2

Wrap<T1, T2, T3>(Func<Func<Task>, T1, T2, T3, Func<Task>>)

public Command Wrap<T1, T2, T3>(Func<Func<Task>, T1, T2, T3, Func<Task>> wrapExecute) where T1 : notnull where T2 : notnull where T3 : notnull

Parameters

wrapExecute Func<Func<Task>, T1, T2, T3, Func<Task>>

Returns

Command

Type Parameters

T1
T2
T3

Events

Executed

public event Action? Executed

Event Type

Action