Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable interface-wide command registration #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant