Skip to main content

CommandCollection

A class in Root.Township, Alta.Console.

Holds every console command module found by reflection. CommandService.CommandCollection owns the one used by the game; mod script bundles are added with Collect and removed with Unload.

Constructors​

MemberWhat it is
CommandCollection()Creates a CommandCollection with default values.

Properties​

MemberWhat it is
HashSet<Module> Modules { get; }The registered top-level modules. A new module replaces any existing one with the same name.

Methods​

MemberWhat it is
List<Module> Collect(Assembly assembly)Scans an assembly for top-level classes with ModuleAttribute and registers each as a module. The returned list is always empty.
static void GetCommands(Type type, Module module)Registers every static method with CommandAttribute on a type as a command of the given module.
static void GetParams(MethodInfo method, Command command)Adds a Parameter for each method argument. A leading ProgressiveHandler marks the command progressive instead; anywhere else it throws.
IEnumerable<CommandPart> GetParts(string[] lower, string[] cased, CommandContext context) (iterator)Yields the matching command parts (modules or commands) from every module, used for autocomplete style lookups.
Module ProcessModule(Type type, Assembly assembly, Module parent = null)Builds a Module from a type with ModuleAttribute, including its commands and submodules. Returns null if the attribute is missing.
IEnumerable<CommandSearchResult> Search(string[] lower, string[] cased, CommandContext context) (iterator)Yields the commands in all modules that match the typed words, for the given caller context.
void Unload(Assembly assembly)Removes every module that came from the given assembly.
8 private and internal methods
MemberWhat it is
private void GetAliases(Type type, CommandPart partBuilder)Private: copies the AliasAttribute aliases of a module class or command method onto its part.
private static void GetAliases(MethodInfo method, CommandPart partBuilder)Private: copies the AliasAttribute aliases of a module class or command method onto its part.
private static void GetPriority(MethodInfo method, CommandPart partBuilder)Private: copies the PriorityAttribute value of a command method onto the command.
private static void GetRequirements(Type type, CommandPart partBuilder)Private: copies the RequirementAttributes of a module class or command method onto its part.
private static void GetRequirements(MethodInfo method, CommandPart partBuilder)Private: copies the RequirementAttributes of a module class or command method onto its part.
private void GetSubmodules(Type parentType, Module parent)Private: processes nested types as submodules. Nested types without ModuleAttribute are searched further down for modules.
private static void ProcessCommand(MethodInfo method, Module module)Private: builds a Command from a method with CommandAttribute, with its aliases, requirements, parameters and priority.
private static void ProcessParam(ParameterInfo param, Command command)Private: adds one Parameter to a command, taking its description from ParamAttribute.

Used in​

Members of other types that take, return or hold a CommandCollection: