RegisterConsoleCommands
Registers application command classes from one or more assemblies. The method scans for concrete implementations of the public command contract and registers them as transient services so ConsoleCommandHandler can receive them from dependency injection.
Use this method after AddConsoleCommands. Pass explicit assemblies when command classes live in another project; relying on the calling assembly is only appropriate when commands are defined in the startup assembly. Command classes should inherit from ConsoleCommandBase; the handler rejects registered command services that do not use the base class.
Usage
csharp
using AlmightyShogun.ConsoleCommands;
builder.Services
.AddConsoleCommands()
.RegisterConsoleCommands(typeof(Program).Assembly);Parameters
assemblies: Assembly[]
Assemblies scanned for concrete command classes. When omitted, the calling assembly is used.
Default: []
Returns
TheIServiceCollection instance with discovered console command classes registered.Type signature
csharp
public IServiceCollection RegisterConsoleCommands(
params Assembly[] assemblies
);