CommandMethod

Wraps a MethodInfo decorated with [Command], providing command metadata, fuzzy name matching, parameter extraction, and invocation.

Definition

Namespace: Paragon.Core.Command Assembly: Paragon.dll

public class CommandMethod

Remarks

CommandMethod is created by CommandProvider during reflection-based discovery. Each instance wraps a single static method and provides:

  • Name matchingIsMatch() performs case-insensitive subsequence matching for fuzzy search

  • Parameter extractionGetParameters() returns CommandParameter[] wrappers around the method's ParameterInfo objects

  • InvocationInvoke() delegates to MethodInfo.Invoke()

The fuzzy matching algorithm in IsMatch() works by checking if the input characters appear in order within the command name (subsequence match), making it suitable for autocomplete-style search.

Quick Lookup

Goal
How

Check if input fuzzy-matches

commandMethod.IsMatch("partial-input")

Get method parameters

commandMethod.GetParameters()

Invoke the command

commandMethod.Invoke(null, args)

Get full signature names

commandMethod.GetSignatureNames()

Properties

Name

The registered command name (from [Command] attribute or method name).

RuntimeOnly

Whether this command is restricted to play mode execution.

ParameterCount

The number of parameters the command method expects.

Constructors

CommandMethod

Parameter
Type
Description

name

string

Registered command name

methodInfo

MethodInfo

The reflected method

runtimeOnly

bool

Whether execution is restricted to play mode

Methods

Invoke

Invokes the underlying method with the given parameters.

Parameter
Type
Description

target

object

Instance to invoke on (null for static methods)

parameters

object[]

Parsed parameter values

Returns: The method's return value, or null for void methods.

IsMatch

Performs case-insensitive subsequence matching against the command name.

Parameter
Type
Description

input

string

Input string (first space-separated token is used as name)

Returns: true if the input characters appear in order within the command name.

circle-info

Fuzzy matching algorithm: The input is split by spaces and only the first token is matched. Each character of the input must appear (in order, case-insensitive) within the command name. For example, "sth" matches "set-health".

GetParameters

Returns the command's parameter descriptors.

Returns: Array of CommandParameter wrappers around the method's ParameterInfo objects.

GetSignatureNames

Yields the command name followed by each parameter name.

Returns: Command name, then each parameter name in order. Useful for displaying command signatures in UI.

Common Pitfalls

circle-exclamation
circle-exclamation

Examples

Fuzzy Match Behavior

Getting Command Signature

See Also

Last updated