I have a DevelopmentConsole class. I am making functionality to register console commands for the subsystems. I don't want the console to know about them but also I don't want them to contain a debug code (like "Console.RegisterCommand...").
I think I should make an additional class hiearachy. For an example I have Player class.
IConsoleBuilder {
RegisterCommand(string command, Func<string[], string> action);
}
PlayerConsoleBuilderClient : ConsoleBuilderClient {
readonly Player _player = ?inject?
public override void Visit(IConsoleBuilder builder) {
// builder.RegisterCommand("GetName", args => _player.Name) ;
}
}
Here I need to use Reflection to find all ConsoleBuilderClient subclasses. It's not a very good idea, is it?
Can you suggest how to do it in a better way?
PlayerConsoleBuilderClient, each object corresponds to a different command. How does that fit together? Looks for me like your are mixing objects and classes, but maybe I misunderstood something.