private void Execute() { if (!_isPromptMode) { throw new InvalidOperationException(); } _isPromptMode = false; if (!_userInput.IsNullOrEmpty()) { AddToHistory(_userInput); } WriteLine(string.Empty); var preOutputLength = _consoleEditor.Model.TextLength; if (!_userInput.IsNullOrEmpty()) { if (_parsedUserInput != null) { try { _commandHandlerService.ExecuteCommand( _parsedUserInput.CommandName.Name, new CommandContext( _provider, _parsedUserInput.Arguments.ToDictionary( arg => arg.Name.Name, arg => (object)arg.Value.Value), Write)); } catch (Exception ex) { WriteLine(ConsoleResources.CommandExecutionException); Write(ex.Message); } } else { Write(ConsoleResources.InvalidInputFormat); } } if (IsDisposed) //Выполненная команда могла закрыть окно. { return; } if (_consoleEditor.Model.TextLength > preOutputLength) { WriteLine(string.Empty); } if (!_isPromptMode) { Prompt(); } }
private void ToolbarButtonClick(object sender, ButtonInfo buttonInfo) { var menuCommand = (IMenuCommand)buttonInfo.Tag; _commandHandlerService.ExecuteCommand( menuCommand.CommandName, new CommandContext(_serviceProvider, menuCommand.Parameters)); }
private void MenuCommandClick(object sender, EventArgs e) { string commandName; IDictionary <string, object> commandParameters; GetMenuItemCommandAndParameters( (IMenuItem)((ToolStripItem)sender).Tag, out commandName, out commandParameters); _commandHandlerService.ExecuteCommand( commandName, new CommandContext(_serviceProvider, commandParameters)); }