Esempio n. 1
0
 private void ExecuteCommand(CommandBase command, List <CommandParameter> commandsParameters, List <string> consoleInputs = null)
 {
     try
     {
         command.OnLog += Command_OnLog;
         command.OnReplacedAutoIncrementInSubCommand += _parameterManager_OnReplacedAutoIncrement;
         if (command.CanExecute(commandsParameters))
         {
             var commandName         = command.CommandName;
             var processedParameters = commandName != "AddParameterCommand"
                     ? _parameterManager.ResolveParameters(StoredDataService, commandsParameters)
                     : commandsParameters;
             var timer = new Stopwatch(); timer.Start();
             command.ConsoleService = new ConsoleService(LoggerService, consoleInputs);
             command.Execute(processedParameters);
             var tab  = ExecutionMode == ExecutionModeTypes.Single ? "" : "\t";
             var time = StringFormats.MillisecondsToHumanTime(timer.ElapsedMilliseconds);
             Log($"{tab}Executed command in {time}");
         }
         else
         {
             command.ExecuteHelp();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
     finally
     {
         command.OnLog -= Command_OnLog;
     }
 }
Esempio n. 2
0
        private void ExecuteCommand(CommandBase command)
        {
            if (!command.CanExecute())
            {
                return;
            }

            command.Execute();
        }
Esempio n. 3
0
        /// <summary>
        /// Method calls <see cref="ICommand.CanExecute"/> on <paramref name="command"/>
        /// and displays the info box when the return value is false.
        /// </summary>
        /// <param name="command">command</param>
        /// <returns>value returned by <paramref name="command"/>.<see cref="ICommand.CanExecute"/></returns>
        public static bool CheckCanExecute(CommandBase command)
        {
            if (!command.CanExecute())
            {
                CommandCantExecuteDialog dialog = new CommandCantExecuteDialog();
                if (!String.IsNullOrEmpty(command.Description))
                {
                    dialog.tbCommand.Content = command.Description;
                }
                else
                {
                    dialog.tbCommand.Content = command.ToString();
                }

                dialog.tbExMsg.Content = String.Empty;
                dialog.tbExMsg.Content = command.ErrorDescription;

                dialog.ShowDialog();
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
 /// <summary>
 /// Evaluates current parser state to determine whether command can be executed.
 /// </summary>
 /// <param name="state">The current parser state.</param>
 /// <returns>Returns <c>true</c> if command can be executed.</returns>
 /// <remarks>Returns <c>true</c> if not overridden.</remarks>
 public virtual bool EvaluateCanExecute(RubberduckParserState state)
 {
     return(state != null && (_command?.CanExecute(state) ?? false));
 }
Esempio n. 5
0
 private bool SpecialEvaluateCanExecute(object parameter)
 {
     return(_parserStatusProvider.Status == ParserState.Ready &&
            (!(parameter is CodeExplorerCustomFolderViewModel folderModel) ||
             _renameFolderCommand.CanExecute(folderModel)));
 }
Esempio n. 6
0
 /// <summary>
 /// Evaluates current parser state to determine whether command can be executed.
 /// </summary>
 /// <param name="state">The current parser state.</param>
 /// <returns>Returns <c>true</c> if command can be executed.</returns>
 /// <remarks>Returns <c>true</c> if not overridden.</remarks>
 public virtual bool EvaluateCanExecute(RubberduckParserState state)
 {
     return(_command.CanExecute(state));
 }
        // METHODS
        /// <summary>
        /// Checks if command can be executed.
        /// </summary>
        /// <param name="parameter">
        /// The parameter that defines if command can be executed.
        /// </param>
        /// <returns>
        /// True — if command can be executed, otherwise — false.
        /// </returns>
        public override bool CanExecute(object parameter)
        {
            Core.Logger.GetLogger.LogAsync(Core.LogMode.Debug, $"Can Execute {nameof(DeleteAvatarFromServerCommand)}");

            return(baseCommand.CanExecute(parameter));
        }
Esempio n. 8
0
 public override bool CanExecute(object parameter)
 {
     return(_command.CanExecute(parameter));
 }