Class CommandInstanceDescriptorExtensions
Extensions for command instance descriptors.
Namespace: TehGM.Wolfringo.Commands
Assembly: Wolfringo.Commands.dll
Syntax
public static class CommandInstanceDescriptorExtensions
Remarks
Extensions in this class will automatically cache results to improve performance.
Methods
| Improve this Doc View SourceGetAllAttributes<T>(ICommandInstanceDescriptor, Boolean)
Gets all custom attributes of specified type.
Declaration
public static IEnumerable<T> GetAllAttributes<T>(this ICommandInstanceDescriptor descriptor, bool includeHandlerAttributes = false)
where T : Attribute
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command instance descriptor to get the value for. |
Boolean | includeHandlerAttributes | Whether handler attributes should also be checked. |
Returns
Type | Description |
---|---|
IEnumerable<T> | Enumerable of found attributes. |
Type Parameters
Name | Description |
---|---|
T | Type of attributes. |
GetAttribute<T>(ICommandInstanceDescriptor, Boolean)
Gets single custom attribute of specified type.
Declaration
public static T GetAttribute<T>(this ICommandInstanceDescriptor descriptor, bool includeHandlerAttributes = false)
where T : Attribute
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command instance descriptor to get the value for. |
Boolean | includeHandlerAttributes | Whether handler attributes should also be checked. |
Returns
Type | Description |
---|---|
T | Found attribute; null if not found. |
Type Parameters
Name | Description |
---|---|
T | Type of attribute. |
GetCaseSensitivityOverride(ICommandInstanceDescriptor)
Checks if the command is overriding default case sensitivity.
Declaration
public static bool? GetCaseSensitivityOverride(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor |
Returns
Type | Description |
---|---|
Nullable<Boolean> | True/false if command is overriding case sensitivity - true to be case sensitive, false to be case insensitive; null if not overriding. |
Remarks
See CaseSensitivityAttribute for more information about command case senstivity.
GetDisplayName(ICommandInstanceDescriptor)
Gets display name for given command instance descriptor.
Declaration
public static string GetDisplayName(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command instance descriptor to get the value for. |
Returns
Type | Description |
---|---|
String | String with determined display name. |
Remarks
Display name is determined in the following order:
- Value of DisplayNameAttribute if present;
- Command text if the command is a standard command (CommandAttribute);
- Regex pattern if the command is a regex command (RegexCommandAttribute);
If the name couldn't be determined, null will be returned.
GetHandlerAttribute(ICommandInstanceDescriptor)
Retrieves CommandHandler attribute for the command's handler.
Declaration
public static CommandsHandlerAttribute GetHandlerAttribute(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command descriptor. |
Returns
Type | Description |
---|---|
CommandsHandlerAttribute | CommandHandler attribute present on the command's handler type; null if not found. |
GetHandlerType(ICommandInstanceDescriptor)
Gets type of the command's handler.
Declaration
public static Type GetHandlerType(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command descriptor. |
Returns
Type | Description |
---|---|
Type | Type of command's handler. |
GetHelpCategory(ICommandInstanceDescriptor)
Gets help category for given command or its handler.
Declaration
public static HelpCategoryAttribute GetHelpCategory(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command instance descriptor to get the value for. |
Returns
Type | Description |
---|---|
HelpCategoryAttribute | Help Category attribute if found on command or its handler; otherwise null. |
GetPrefixOverride(ICommandInstanceDescriptor)
Gets command's prefix override.
Declaration
public static string GetPrefixOverride(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command descriptor. |
Returns
Type | Description |
---|---|
String | Prefix value. |
GetPrefixRequirementOverride(ICommandInstanceDescriptor)
Gets command's prefix requirement override.
Declaration
public static PrefixRequirement? GetPrefixRequirementOverride(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command descriptor. |
Returns
Type | Description |
---|---|
Nullable<PrefixRequirement> | Prefix requirement value. |
GetPriority(ICommandInstanceDescriptor)
Gets command's priority.
Declaration
public static int GetPriority(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command descriptor. |
Returns
Type | Description |
---|---|
Int32 | Command's priority value. |
Remarks
See PriorityAttribute for more information about command priorities.
See Also
| Improve this Doc View SourceGetRequirements(ICommandInstanceDescriptor)
Gets command's pre-execute checks.
Declaration
public static IEnumerable<CommandRequirementAttribute> GetRequirements(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command descriptor. |
Returns
Type | Description |
---|---|
IEnumerable<CommandRequirementAttribute> | Enumerable on all pre-execute checks on the command's method and handler type. |
GetSummary(ICommandInstanceDescriptor)
Gets summary text for given command instance descriptor.
Declaration
public static string GetSummary(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command instance descriptor to get the value for. |
Returns
Type | Description |
---|---|
String | Summary text if found on the command; otherwise null. |
IsHidden(ICommandInstanceDescriptor)
Checks if the command or its handler are hidden.
Declaration
public static bool IsHidden(this ICommandInstanceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
ICommandInstanceDescriptor | descriptor | Command instance descriptor to get the value for. |
Returns
Type | Description |
---|---|
Boolean | True if the command or its handler are marked as hidden; otherwise false. |