Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.

Enable interface-wide command registration#165

Open
DavidL344 wants to merge 2 commits intomayuki:masterfrom
DavidL344:feature/interface-commands
Open

Enable interface-wide command registration#165
DavidL344 wants to merge 2 commits intomayuki:masterfrom
DavidL344:feature/interface-commands

Conversation

@DavidL344
Copy link
Contributor

This PR enables registering all command classes inheriting from a shared interface.

// Rather than adding all command classes individually...
app.AddCommands<MyCommand1>();
app.AddCommands<MyCommand2>();
app.AddCommands<MyCommand3>();

// ...you can add an interface the command classes inherit from!
interface ICommands { }
class MyCommand1 : ICommands { ... }
class MyCommand2 : ICommands { ... }
class MyCommand3 : ICommands { ... }

app.AddCommands<ICommands>();

This could also be potentially useful for command registration branching, where certain requirements need to be met for a specific set of commands to work:

// For debugging
if (Debugger.IsAttached)
{
    app.AddCommands<IDebugCommands>();
}

// For Windows-specific features of a cross-platform tool
if (OperatingSystem.IsWindows())
{
    app.AddCommands<IWindowsCommands>();
}

Adds support for registering multiple command classes using a shared interface
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant