Exemplo n.º 1
0
            public Task <byte[]> InvokeAsync(TParameters parameters, IProgress <OperationProgress> progress, CancellationToken cancellationToken)
            {
                Verify.Argument.IsNotNull(parameters, nameof(parameters));

                var command        = _commandFactory(parameters);
                var stdInReceiver  = new AsyncBytesReader();
                var stdErrReceiver = new AsyncTextReader();

                return(_commandExecutor
                       .ExecuteCommandAsync(
                           command,
                           stdInReceiver,
                           stdErrReceiver,
                           CommandExecutionFlags.None,
                           cancellationToken)
                       .ContinueWith(
                           t =>
                {
                    var exitCode = TaskUtility.UnwrapResult(t);
                    if (exitCode != 0)
                    {
                        throw new GitException(stdErrReceiver.GetText());
                    }
                    return stdInReceiver.GetBytes();
                },
                           cancellationToken,
                           TaskContinuationOptions.ExecuteSynchronously,
                           TaskScheduler.Default));
            }
Exemplo n.º 2
0
            public byte[] Invoke(TParameters parameters)
            {
                Verify.Argument.IsNotNull(parameters, nameof(parameters));

                var command        = _commandFactory(parameters);
                var stdInReceiver  = new AsyncBytesReader();
                var stdErrReceiver = new AsyncTextReader();
                var exitCode       = _commandExecutor.ExecuteCommand(
                    command,
                    stdInReceiver,
                    stdErrReceiver,
                    CommandExecutionFlags.None);

                if (exitCode != 0)
                {
                    throw new GitException(stdErrReceiver.GetText());
                }
                return(stdInReceiver.GetBytes());
            }