Class CommandAttributeUtility
Utility methods for accessing command attribute information on the types in an assembly.
Inherited Members
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
public class CommandAttributeUtility
Constructors
| Edit this page View SourceCommandAttributeUtility(ICommandProgramOptions)
Declaration
public CommandAttributeUtility(ICommandProgramOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| ICommandProgramOptions | options |
Methods
| Edit this page View SourceGetAllCommandUsages(Assembly)
Creates a list of command usages for all the commands in an assembly
Declaration
public List<CommandInfo> GetAllCommandUsages(Assembly asm)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | asm | Assembly to check |
Returns
| Type | Description |
|---|---|
| List<CommandInfo> | List of command usages |
GetAvailableCommandAttributes(Assembly)
Get all the command attributes for all the command types in an assembly.
Declaration
public List<CommandAttribute> GetAvailableCommandAttributes(Assembly containingAssembly)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | containingAssembly | Assembly to check |
Returns
| Type | Description |
|---|---|
| List<CommandAttribute> | List of command attributes from this assembly. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
GetAvailableCommandNames(Assembly)
Get the list of command names in an assembly
Declaration
public List<string> GetAvailableCommandNames(Assembly containingAssembly)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | containingAssembly | Assembly to examine |
Returns
| Type | Description |
|---|---|
| List<string> | List of command names for all classes with a CommandAttribute in the assembly |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
GetAvailableCommandType(Assembly, string)
Gets command type from an assembly by command name.
Declaration
public Type? GetAvailableCommandType(Assembly containingAssembly, string commandName)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | containingAssembly | Assembly containing the commands |
| string | commandName | Command name to find. This is typically args[0] from the command line. |
Returns
| Type | Description |
|---|---|
| Type | Instance of System.Type for the matching command or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
GetCommand(string[], Assembly)
Gets a populated instance of a command using arguments from the command line. This uses args[0] as the command name. The rest of the arguments are used as argument values to the command.
Declaration
public CommandBase? GetCommand(string[] args, Assembly containingAssembly)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | args | Command line arguments |
| Assembly | containingAssembly | Assembly that contains the commands |
Returns
| Type | Description |
|---|---|
| CommandBase | Populated command |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | |
| ArgumentException | |
| MissingArgumentException |
GetCommandAttributeForCommandName(Assembly, string)
Get a command argument for a command by command name.
Declaration
public CommandAttribute? GetCommandAttributeForCommandName(Assembly containingAssembly, string commandName)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | containingAssembly | Assembly containing the commands |
| string | commandName | Command name to find. This is typically args[0] from the command line. |
Returns
| Type | Description |
|---|---|
| CommandAttribute | Command argument for the command or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |