예제 #1
0
        //Listing 19-25. Custom Button .NET Code

        private void CustomButton_Click(object sender, RoutedEventArgs e)
        {
            IExecutable cmd = (IExecutable)((IContentItem)this.DataContext).Details;

            if (cmd != null && cmd.CanExecuteAsync)
            {
                cmd.ExecuteAsync();
            }
        }
예제 #2
0
 public static ExecutionResult Execute(
     this IExecutable executable,
     ArgumentString arguments,
     Action <StreamWriter>?writeInput = null,
     Encoding?outputEncoding          = null,
     bool stripAnsiEscapeCodes        = true)
 {
     return(GitUI.ThreadHelper.JoinableTaskFactory.Run(
                () => executable.ExecuteAsync(arguments, writeInput, outputEncoding, stripAnsiEscapeCodes)));
 }
예제 #3
0
        public static async Task <IEnumerable <string> > GetOutputLinesAsync(
            this IExecutable executable,
            ArgumentString arguments         = default,
            Action <StreamWriter>?writeInput = null,
            Encoding?outputEncoding          = null,
            bool stripAnsiEscapeCodes        = true)
        {
            var result = await executable.ExecuteAsync(arguments, writeInput, outputEncoding, stripAnsiEscapeCodes);

            return(result.StandardOutput.SplitLines().Concat(result.StandardError.SplitLines()));
        }
예제 #4
0
 private async Task InnerExecuteAsync(IExecutable executable, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     try
     {
         await(executable.ExecuteAsync(cancellationToken)).ConfigureAwait(false);
     }
     finally
     {
         RegisterCleanupActions(executable);
     }
 }
예제 #5
0
 private async Task InnerExecuteAsync(IExecutable executable, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     try
     {
         await(executable.ExecuteAsync(cancellationToken)).ConfigureAwait(false);
     }
     finally
     {
         if (executable.PropertySpaces != null)
         {
             executedSpaces.UnionWith(executable.PropertySpaces);
         }
         RegisterCleanupActions(executable);
     }
 }
예제 #6
0
        /// <summary>
        /// Executes the command given specific arguments as input.
        /// </summary>
        /// <param name="correlationId">Unique correlation/transaction id.</param>
        /// <param name="args">Command arguments.</param>
        /// <returns>Execution result.</returns>
        public async Task <object> ExecuteAsync(string correlationId, Parameters args)
        {
            if (_schema != null)
            {
                _schema.ValidateAndThrowException(correlationId, args);
            }

            try
            {
                return(await _function.ExecuteAsync(correlationId, args));
            }
            catch (Exception ex)
            {
                throw new InvocationException(
                          correlationId,
                          "EXEC_FAILED",
                          "Execution " + Name + " failed: " + ex
                          )
                      .WithDetails("command", Name)
                      .Wrap(ex);
            }
        }