Class Command
- Namespace
- Tripous
- Assembly
- Tripous.dll
Represents a named application command.
A command may execute a synchronous or asynchronous callback, open a form, or act as a container for child commands.
public class Command : BaseDef, IDef, IJsonLoadable, INotifyPropertyChanged
- Inheritance
-
Command
- Implements
- Inherited Members
- Extension Methods
Constructors
Command()
Constructor.
public Command()
Command(string)
Constructs a command with the specified name.
public Command(string Name)
Parameters
Namestring
Properties
CanExecuteFunc
Gets or sets the callback that determines whether this command can execute.
public Func<Command, bool> CanExecuteFunc { get; set; }
Property Value
Commands
Gets the child commands of this command.
public DefList<Command> Commands { get; init; }
Property Value
ExecuteAsyncFunc
Gets or sets the asynchronous callback that executes this command.
public Func<Command, Task<object>> ExecuteAsyncFunc { get; set; }
Property Value
ExecuteFunc
Gets or sets the synchronous callback that executes this command.
public Func<Command, object> ExecuteFunc { get; set; }
Property Value
Form
Gets the form name opened by this command.
public string Form { get; init; }
Property Value
HasChildren
Gets a value indicating whether this command contains child commands.
public bool HasChildren { get; }
Property Value
ImageFileName
Gets the file name of the image used when this command is displayed in menus, toolbars or tree views.
public string ImageFileName { get; init; }
Property Value
IsAsync
Gets a value indicating whether this command has an asynchronous callback.
public bool IsAsync { get; }
Property Value
IsSerializable
Gets a value indicating whether this command should be serialized.
[JsonIgnore]
public override bool IsSerializable { get; }
Property Value
IsSync
Gets a value indicating whether this command has a synchronous callback.
public bool IsSync { get; }
Property Value
IsToggle
Gets or sets a value indicating whether this command toggles a Boolean value.
public bool IsToggle { get; set; }
Property Value
SecurityLevel
Gets or sets the minimum user level required to view or execute this command.
public UserLevel SecurityLevel { get; set; }
Property Value
Methods
CanAccess(AppUser)
Returns true when the specified user may see or execute this command.
public bool CanAccess(AppUser User)
Parameters
UserAppUser
Returns
CanExecute()
Returns true when this command can execute.
public bool CanExecute()
Returns
Create(string, Func<Command, object>, string, string, string)
Creates a synchronous command with optional form, title key and image file name.
public static Command Create(string Name, Func<Command, object> ExecuteFunc, string Form = null, string TitleKey = null, string ImageFileName = null)
Parameters
Returns
Create(string, string, Func<Command, object>, string)
Creates a synchronous command with a name, image file name, callback and optional title key.
public static Command Create(string Name, string ImageFileName, Func<Command, object> ExecuteFunc, string TitleKey = null)
Parameters
Returns
Create(string, string, string)
Creates a command with a name, image file name and optional title key.
public static Command Create(string Name, string ImageFileName, string TitleKey = null)
Parameters
Returns
CreateAsync(string, Func<Command, Task<object>>, string, string, string)
Creates an asynchronous command with optional form, title key and image file name.
public static Command CreateAsync(string Name, Func<Command, Task<object>> ExecuteAsyncFunc, string Form = null, string TitleKey = null, string ImageFileName = null)
Parameters
NamestringExecuteAsyncFuncFunc<Command, Task<object>>FormstringTitleKeystringImageFileNamestring
Returns
CreateAsync(string, string, Func<Command, Task<object>>, string)
Creates an asynchronous command with a name, image file name, callback and optional title key.
public static Command CreateAsync(string Name, string ImageFileName, Func<Command, Task<object>> ExecuteAsyncFunc, string TitleKey = null)
Parameters
Returns
CreateForm(string, string, string, string)
Creates a command that opens a form.
public static Command CreateForm(string Name, string Form, string TitleKey = null, string ImageFileName = null)
Parameters
Returns
Execute()
Executes this command synchronously.
public object Execute()
Returns
ExecuteAsync()
Executes this command asynchronously.
public Task<object> ExecuteAsync()