Skip to content
New issue

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

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

Already on GitHub? # to your account

Support custom command types #68

Open
tommasobertoni opened this issue Mar 9, 2021 · 0 comments
Open

Support custom command types #68

tommasobertoni opened this issue Mar 9, 2021 · 0 comments
Labels

Comments

@tommasobertoni
Copy link
Contributor

A consumer may add additional properties to a command, like:

class MyCommand : Command { /* ... */ }

var myCmd = new MyCommand
{
    Id = "FindYellowBox",
    VoiceTriggers = new[] { "Find yellow box" },
    Object = "box",
    Color = "yellow",
};

At the moment in order to get this info back, the consumer needs to cast the command to its type:

covox.Recognized += (Command command, _) =>
{
    var myCmd = (MyCommand)command;
    // ...
};

Proposal:
Allow to create a typed instance of the engine, and accept/return only typed commands:

var covox = new CovoxEngine<MyCommand>(config);

var cmds = new[] { new MyCommand() };
covox.RegisterCommands(cmds);

covox.Recognized += (MyCommand command, _) => { /* ... */ };
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant