Table of Contents

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

Name string

Properties

CanExecuteFunc

Gets or sets the callback that determines whether this command can execute.

public Func<Command, bool> CanExecuteFunc { get; set; }

Property Value

Func<Command, bool>

Commands

Gets the child commands of this command.

public DefList<Command> Commands { get; init; }

Property Value

DefList<Command>

ExecuteAsyncFunc

Gets or sets the asynchronous callback that executes this command.

public Func<Command, Task<object>> ExecuteAsyncFunc { get; set; }

Property Value

Func<Command, Task<object>>

ExecuteFunc

Gets or sets the synchronous callback that executes this command.

public Func<Command, object> ExecuteFunc { get; set; }

Property Value

Func<Command, object>

Form

Gets the form name opened by this command.

public string Form { get; init; }

Property Value

string

HasChildren

Gets a value indicating whether this command contains child commands.

public bool HasChildren { get; }

Property Value

bool

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

string

IsAsync

Gets a value indicating whether this command has an asynchronous callback.

public bool IsAsync { get; }

Property Value

bool

IsSerializable

Gets a value indicating whether this command should be serialized.

[JsonIgnore]
public override bool IsSerializable { get; }

Property Value

bool

IsSync

Gets a value indicating whether this command has a synchronous callback.

public bool IsSync { get; }

Property Value

bool

IsToggle

Gets or sets a value indicating whether this command toggles a Boolean value.

public bool IsToggle { get; set; }

Property Value

bool

SecurityLevel

Gets or sets the minimum user level required to view or execute this command.

public UserLevel SecurityLevel { get; set; }

Property Value

UserLevel

Methods

CanAccess(AppUser)

Returns true when the specified user may see or execute this command.

public bool CanAccess(AppUser User)

Parameters

User AppUser

Returns

bool

CanExecute()

Returns true when this command can execute.

public bool CanExecute()

Returns

bool

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

Name string
ExecuteFunc Func<Command, object>
Form string
TitleKey string
ImageFileName string

Returns

Command

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

Name string
ImageFileName string
ExecuteFunc Func<Command, object>
TitleKey string

Returns

Command

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

Name string
ImageFileName string
TitleKey string

Returns

Command

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

Name string
ExecuteAsyncFunc Func<Command, Task<object>>
Form string
TitleKey string
ImageFileName string

Returns

Command

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

Name string
ImageFileName string
ExecuteAsyncFunc Func<Command, Task<object>>
TitleKey string

Returns

Command

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

Name string
Form string
TitleKey string
ImageFileName string

Returns

Command

Execute()

Executes this command synchronously.

public object Execute()

Returns

object

ExecuteAsync()

Executes this command asynchronously.

public Task<object> ExecuteAsync()

Returns

Task<object>