public void DispatchCommand(ICommandInput commandInput) { ICommand cmd; if ((cmd = CommandsCatalog.FindByName(commandInput.CommandName)) == null && DefaultCommand == null) { Console.WriteLine("'{0}' command not found", commandInput.CommandName); return; } if (cmd == null) { cmd = DefaultCommand; commandInput = commandInput.ToDefaultCommand(DefaultCommand.Name); } if (DebugMode || Debugger.IsAttached) { DispatchCommandWithoutErrorHandling(commandInput, cmd); } else { DispatchCommandWithErrorHandling(commandInput, cmd); } }
public CommandDispatcher(CommandsCatalog commandsCatalog) { CommandsCatalog = commandsCatalog ?? new CommandsCatalog(); Initialize(); DefaultCommand = CommandsCatalog.GetDefaultCommand(); }