Class Command
An immutable command. A command is a specific action or a set of actions that a user or an application requests the underlying system to perform. It can be a simple action such as invoking a system method or an OS command or representing a complex operation that calls a set of protected APIs over the internal or external network. A command can virtually do anything in the context of your application or service.
public sealed class Command
- Inheritance
-
Command
- Inherited Members
Constructors
Command(CommandDescriptor, Arguments?, Options?)
Initializes a new instance.
public Command(CommandDescriptor commandDescriptor, Arguments? arguments = null, Options? options = null)
Parameters
commandDescriptor
CommandDescriptorThe command descriptor.
arguments
ArgumentsThe command arguments.
options
OptionsThe command options.
Properties
Arguments
The command arguments.
public Arguments? Arguments { get; set; }
Property Value
CustomProperties
The command custom properties.
public Dictionary<string, object>? CustomProperties { get; }
Property Value
Description
The command description.
public string? Description { get; }
Property Value
Descriptor
The command descriptor.
public CommandDescriptor Descriptor { get; }
Property Value
Id
The command id unique.
public string Id { get; }
Property Value
Name
The command name.
public string Name { get; }
Property Value
Options
The command options.
public Options? Options { get; set; }
Property Value
Methods
GetRequiredOptionValue<TValue>(string)
Get the option value for the specified identifier.
public TValue GetRequiredOptionValue<TValue>(string idOrAlias)
Parameters
idOrAlias
stringThe option id or its alias.
Returns
- TValue
The option value.
Type Parameters
TValue
The type of value.
Exceptions
- TerminalException
If the option is not supported.
TryGetArgument(string, out Argument?)
Attempts to get the argument for the specified identifier.
public bool TryGetArgument(string id, out Argument? argument)
Parameters
Returns
- bool
true
if the argument is found.
TryGetArgumentValue<TValue>(string, out TValue?)
Attempts to get the argument value for the specified index.
public bool TryGetArgumentValue<TValue>(string id, out TValue? value)
Parameters
id
stringThe argument identifier.
value
TValueThe argument value.
Returns
- bool
The option value.
Type Parameters
TValue
The type of value.
Exceptions
- TerminalException
If the argument is not supported.
TryGetOption(string, out Option?)
Attempts to get the option for the specified identifier.
public bool TryGetOption(string idOrAlias, out Option? option)
Parameters
Returns
- bool
true
if the option is found.
TryGetOptionValue<TValue>(string, out TValue?)
Attempts to get the option value for the specified identifier.
public bool TryGetOptionValue<TValue>(string idOrAlias, out TValue? value)
Parameters
idOrAlias
stringThe option id or its alias.
value
TValueThe option value.
Returns
- bool
The option value.
Type Parameters
TValue
The type of value.
Exceptions
- TerminalException
If the option is not supported.