Exemplo n.º 1
0
        public bool Execute(IConsole console, string command, params object[] inputs)
        {
            if (console == null)
            {
                throw new ArgumentNullException(nameof(console));
            }

            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            NuGetPowerShellUsage.RaiseCommandExecuteEvent(isPMC: console is IWpfConsole);

            // since install.ps1/uninstall.ps1 could depend on init scripts, so we need to make sure
            // to run it once for each solution
            NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await ExecuteInitScriptsAsync();
            });

            NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleCommandExecutionBegin);
            ActiveConsole = console;

            string fullCommand;

            if (ComplexCommand.AddLine(command, out fullCommand) &&
                !string.IsNullOrEmpty(fullCommand))
            {
                // create a new token source with each command since CTS aren't usable once cancelled.
                _tokenSource = new CancellationTokenSource();
                _token       = _tokenSource.Token;
                return(ExecuteHost(fullCommand, command, inputs));
            }

            return(false); // constructing multi-line command
        }
Exemplo n.º 2
0
        public bool Execute(IConsole console, string command, params object[] inputs)
        {
            if (console == null)
            {
                throw new ArgumentNullException("console");
            }

            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleCommandExecutionBegin);
            ActiveConsole = console;

            string fullCommand;

            if (ComplexCommand.AddLine(command, out fullCommand) && !string.IsNullOrEmpty(fullCommand))
            {
                return(ExecuteHost(fullCommand, command, inputs));
            }

            return(false); // constructing multi-line command
        }
 /// <summary>
 /// Execute complex command; save operation records and sender acount balance
 /// </summary>
 /// <param name="complexCommand">complex command to execute and save</param>
 /// <param name="sender">sender account</param>
 public void ExecuteAndSave(ComplexCommand complexCommand, IPublicAccount sender)
 {
     complexCommand.Execute();
     _dataInserter.SaveOperations(complexCommand.GetExecutedOperations());
     _dataInserter.SaveAccountBalance(sender);
 }
 /// <summary>
 /// Execute complex command; save operation records and receiver and sender acount balance
 /// </summary>
 /// <param name="complexCommand">complex command to execute and save</param>
 /// <param name="sender">sender account</param>
 /// <param name="receiver">receiver account</param>
 public void ExecuteAndSave(ComplexCommand complexCommand, IPublicAccount sender, IPublicAccount receiver)
 {
     ExecuteAndSave(complexCommand, sender);
     _dataInserter.SaveAccountBalance(receiver);
 }
Exemplo n.º 5
0
 public void Abort()
 {
     ExecutingPipeline?.StopAsync();
     ComplexCommand.Clear();
 }
Exemplo n.º 6
0
 public SelectionOptionViewModel()
 {
     ViewSelectionCommand = new ComplexCommand(OnOptionSelected, canExecute => true);
 }
 public SearchViewModel()
 {
     SearchOptionCommand = new ComplexCommand(OnSearchOptionSelected, canExecute => true);
 }