Class Command
public class Command
- Inheritance
-
Command
- Derived
- Inherited Members
Constructors
Command(Func<string>, Action)
public Command(Func<string> getLabel, Action execute)
Parameters
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
getLabelFunc<string>executeActioncanExecuteFunc<bool>isVisibleFunc<IServices, bool>primarybool
Command(Func<string>, Func<Task>)
public Command(Func<string> getLabel, Func<Task> execute)
Parameters
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
getLabelFunc<string>executeFunc<Task>canExecuteFunc<bool>isVisibleFunc<IServices, bool>primarybool
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
getLabelFunc<string>executeFunc<Task>canExecuteFunc<Task<bool>>isVisibleFunc<IServices, Task<bool>>primarybool
Command(string, Action)
public Command(string label, Action execute)
Parameters
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
Command(string, Func<Task>)
public Command(string label, Func<Task> execute)
Parameters
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
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
labelstringexecuteFunc<Task>canExecuteFunc<Task<bool>>isVisibleFunc<IServices, Task<bool>>primarybool
Properties
CanAlwaysExecute
public bool CanAlwaysExecute { get; }
Property Value
Icon
The command's optional icon name.
public string? Icon { get; }
Property Value
IsAlwaysVisible
public bool IsAlwaysVisible { get; }
Property Value
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
Label
The command's variable display identity.
public string Label { get; }
Property Value
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
Shortcut
Activates this command's presenting control (if it is visible and enabled).
public KeyboardShortcut? Shortcut { get; }
Property Value
Tier
The display-hierarchy level this command is presented at when rendered as a button.
public ButtonTier Tier { get; }
Property Value
Methods
CanExecute()
public Task<bool> CanExecute()
Returns
Enable(Func<bool>)
public Command Enable(Func<bool> canExecute)
Parameters
Returns
Enable(Func<Task<bool>>)
public Command Enable(Func<Task<bool>> canExecute)
Parameters
Returns
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
providerIServiceProvideronErrorAction<Exception>
Returns
IsVisible(IServices)
public Task<bool> IsVisible(IServices services)
Parameters
servicesIServices
Returns
Rename(Func<string>)
public Command Rename(Func<string> getLabel)
Parameters
Returns
Rename(string)
public Command Rename(string label)
Parameters
labelstring
Returns
Show(Func<IServices, bool>)
public Command Show(Func<IServices, bool> isVisible)
Parameters
Returns
Show(Func<IServices, Task<bool>>)
public Command Show(Func<IServices, Task<bool>> isVisible)
Parameters
Returns
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
intentValidationIntent?blockAtMessageLevel
Returns
VisibleWhen(Func<IServices, bool>)
[Obsolete("Use Show()")]
public Command VisibleWhen(Func<IServices, bool> isVisible)
Parameters
Returns
VisibleWhen(Func<IServices, Task<bool>>)
[Obsolete("Use Show()")]
public Command VisibleWhen(Func<IServices, Task<bool>> isVisible)
Parameters
Returns
WithIcon(string)
Names an icon from the Lucide set to be displayed alongside the command's label.
public Command WithIcon(string icon)
Parameters
iconstring
Returns
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
levelMessageLevel?
Returns
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
routestringtitlestringcontentRenderFragment
Returns
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
routestringtitlestringcontentRenderFragment<IReadOnlyDictionary<string, object>>
Returns
WithPrimary(bool)
[Obsolete("Use WithTier()")]
public Command WithPrimary(bool primary)
Parameters
primarybool
Returns
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
keycharA single-character KeyboardEvent.key value, lowercased.
modifiersShortcutModifiersMust include CmdOrCtrl, Ctrl or Alt.
Returns
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
keystringA KeyboardEvent.key value, such as "s", "F5" or "ArrowLeft".
modifiersShortcutModifiersMust include CmdOrCtrl, Ctrl or Alt.
Returns
WithShortcut(KeyboardShortcut)
Declares the shortcut that activates this command's presenting control (if it is visible and enabled).
public Command WithShortcut(KeyboardShortcut shortcut)
Parameters
shortcutKeyboardShortcut
Returns
WithTier(ButtonTier)
Declares the display-hierarchy level of this command when presented as a button.
public Command WithTier(ButtonTier tier)
Parameters
tierButtonTier
Returns
WithValidation(ValidationIntent?, MessageLevel)
Declares the validation this command runs before executing.
public Command WithValidation(ValidationIntent? intent = null, MessageLevel blockAt = MessageLevel.Error)
Parameters
intentValidationIntent?Passed to validation rules. Defaults to Save.
blockAtMessageLevelPrevents execution at this level of findings.
Returns
Wrap(Func<Func<Task>, Func<Task>>)
public Command Wrap(Func<Func<Task>, Func<Task>> wrapExecute)
Parameters
Returns
Wrap<T>(Func<Func<Task>, T, Func<Task>>)
public Command Wrap<T>(Func<Func<Task>, T, Func<Task>> wrapExecute) where T : notnull
Parameters
Returns
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
Returns
Type Parameters
T1T2
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
Returns
Type Parameters
T1T2T3
Events
Executed
public event Action? Executed