CommandProvider
Static registry that discovers and stores all command methods at initialization. Scans all Paragon assemblies via reflection for methods decorated with [Command] (or its subclasses [RuntimeCommand], [EditorCommand]) and builds a dictionary of CommandMethod instances keyed by name. Provides lookup, query, and fuzzy-match APIs used by the Command facade and the CommandToolbar.
Definition
Namespace: Paragon.Core.Command Assembly: Paragon.dll
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoad]
#else
[RuntimeInitializeOnLoad]
#endif
public static class CommandProviderRemarks
CommandProvider initializes in its static constructor, which runs:
In the editor — via
[InitializeOnLoad]when the editor loads or recompiles.At runtime — via the custom
[RuntimeInitializeOnLoad]attribute, which triggers the static constructor before scene load.
Discovery Algorithm
Collect all loaded assemblies whose
FullNamestarts with"Paragon".For each type in those assemblies, inspect all static methods (public and non-public).
If a method has
[Command](or a derived attribute), register it as aCommandMethod.The command name is either the
CommandAttribute.Name(if provided) or the method's own name.
Quick Lookup
Get a command by exact name
CommandProvider.GetCommand("MyCommand")
Try-get a command safely
CommandProvider.TryGetCommand("name", out var cmd)
Fuzzy match commands
CommandProvider.GetMatchingCommands("partial")
List all commands
CommandProvider.GetCommands()
Methods
GetCommand
Returns the CommandMethod with the given name. Throws KeyNotFoundException if not found.
name
string
Exact command name
Returns: The matching CommandMethod.
TryGetCommand
Attempts to retrieve a CommandMethod by exact name.
name
string
Exact command name
commandMethod
out CommandMethod
The result if found
Returns: true if a command with that name exists.
GetMatchingCommands
Returns all commands whose names fuzzy-match the given input string. Delegates to each CommandMethod.IsMatch().
input
string
Partial input to match against
Returns: All matching CommandMethod instances (unscored — for scored results use CommandSearch).
GetCommands
Returns all registered commands.
Returns: All CommandMethod instances in the registry.
Common Pitfalls
Only scans Paragon assemblies The discovery filter is assembly.FullName.StartsWith("Paragon"). Commands defined in assemblies with different naming conventions will not be found.
Duplicate command names If two methods share the same command name (via [Command("sameName")]), Dictionary.Add will throw an ArgumentException during initialization. Command names must be unique.
Only static methods are discovered The reflection scan uses BindingFlags.Static. Instance methods with [Command] will be silently ignored.
See Also
Command — static facade that delegates to
CommandProviderCommandSearch — fuzzy search with scoring
CommandMethod — the registered command wrapper
CommandAttribute — the attribute marking methods as commands
Command System — system overview
Last updated