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 CommandProvider

Remarks

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

  1. Collect all loaded assemblies whose FullName starts with "Paragon".

  2. For each type in those assemblies, inspect all static methods (public and non-public).

  3. If a method has [Command] (or a derived attribute), register it as a CommandMethod.

  4. The command name is either the CommandAttribute.Name (if provided) or the method's own name.

Quick Lookup

Goal
How

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.

Parameter
Type
Description

name

string

Exact command name

Returns: The matching CommandMethod.

TryGetCommand

Attempts to retrieve a CommandMethod by exact name.

Parameter
Type
Description

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().

Parameter
Type
Description

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

circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated