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 CommandMethodRemarks
CommandMethod is created by CommandProvider during reflection-based discovery. Each instance wraps a single static method and provides:
Name matching —
IsMatch()performs case-insensitive subsequence matching for fuzzy searchParameter extraction —
GetParameters()returnsCommandParameter[]wrappers around the method'sParameterInfoobjectsInvocation —
Invoke()delegates toMethodInfo.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
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
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.
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.
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.
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
IsMatch splits input by spaces Only the first token (before the first space) is used for name matching. Arguments after the space are ignored by IsMatch().
Invoke target should be null for static commands All commands discovered by CommandProvider are static methods. Pass null as the target parameter.
Examples
Fuzzy Match Behavior
Getting Command Signature
See Also
Command — Static API that delegates to
CommandMethodCommandParameter — Parameter wrappers returned by
GetParameters()CommandAttribute — Attribute that marks methods for discovery
Last updated