Ejemplo n.º 1
0
        /// <inheritdoc/>
        protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Owner != null && Name != null && ArchiveFormat != null && Reference != null && Timeout != null)
            {
                var ownerValue         = Owner.GetValue(dc.State);
                var nameValue          = Name.GetValue(dc.State);
                var archiveFormatValue = ArchiveFormat.GetValue(dc.State);
                var referenceValue     = Reference.GetValue(dc.State);
                var timeoutValue       = Timeout.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive(ownerValue, nameValue, archiveFormatValue, referenceValue, timeoutValue).ConfigureAwait(false));
            }
            if (Owner != null && Name != null && ArchiveFormat != null && Reference != null)
            {
                var ownerValue         = Owner.GetValue(dc.State);
                var nameValue          = Name.GetValue(dc.State);
                var archiveFormatValue = ArchiveFormat.GetValue(dc.State);
                var referenceValue     = Reference.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive(ownerValue, nameValue, archiveFormatValue, referenceValue).ConfigureAwait(false));
            }
            if (RepositoryId != null && ArchiveFormat != null && Reference != null && Timeout != null)
            {
                var repositoryIdValue  = RepositoryId.GetValue(dc.State);
                var archiveFormatValue = ArchiveFormat.GetValue(dc.State);
                var referenceValue     = Reference.GetValue(dc.State);
                var timeoutValue       = Timeout.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive((Int64)repositoryIdValue, archiveFormatValue, referenceValue, timeoutValue).ConfigureAwait(false));
            }
            if (Owner != null && Name != null && ArchiveFormat != null)
            {
                var ownerValue         = Owner.GetValue(dc.State);
                var nameValue          = Name.GetValue(dc.State);
                var archiveFormatValue = ArchiveFormat.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive(ownerValue, nameValue, archiveFormatValue).ConfigureAwait(false));
            }
            if (RepositoryId != null && ArchiveFormat != null && Reference != null)
            {
                var repositoryIdValue  = RepositoryId.GetValue(dc.State);
                var archiveFormatValue = ArchiveFormat.GetValue(dc.State);
                var referenceValue     = Reference.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive((Int64)repositoryIdValue, archiveFormatValue, referenceValue).ConfigureAwait(false));
            }
            if (Owner != null && Name != null)
            {
                var ownerValue = Owner.GetValue(dc.State);
                var nameValue  = Name.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive(ownerValue, nameValue).ConfigureAwait(false));
            }
            if (RepositoryId != null && ArchiveFormat != null)
            {
                var repositoryIdValue  = RepositoryId.GetValue(dc.State);
                var archiveFormatValue = ArchiveFormat.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive((Int64)repositoryIdValue, archiveFormatValue).ConfigureAwait(false));
            }
            if (RepositoryId != null)
            {
                var repositoryIdValue = RepositoryId.GetValue(dc.State);
                return(await gitHubClient.Repository.Content.GetArchive((Int64)repositoryIdValue).ConfigureAwait(false));
            }

            throw new ArgumentNullException("Required [] arguments missing for GitHubClient.Repository.Content.GetArchive");
        }
Ejemplo n.º 2
0
        protected sealed override bool run()
        {
            var startInfo = StartInfo.GetValue();

            using (var process = new Process()
            {
                StartInfo = startInfo
            })
            {
                if (DataReceiveAction != null)
                {
                    process.OutputDataReceived += (_, e) => DataReceiveAction.GetValue()(e);
                }

                if (ErrorReceiveAction != null)
                {
                    process.ErrorDataReceived += (_, e) => ErrorReceiveAction.GetValue()(e);
                }

                if (!process.Start())
                {
                    return(false);
                }

                if (startInfo.RedirectStandardOutput)
                {
                    process.BeginOutputReadLine();
                }

                if (startInfo.RedirectStandardError)
                {
                    process.BeginErrorReadLine();
                }

                if (Timeout == null)
                {
                    process.WaitForExit();
                }
                else
                {
                    process.WaitForExit(Timeout.GetValue());
                }

                if (startInfo.RedirectStandardInput)
                {
                    process.CancelOutputRead();
                }

                if (startInfo.RedirectStandardError)
                {
                    process.CancelErrorRead();
                }

                var exitCode = process.ExitCode;

                if (ExitCode != null)
                {
                    ExitCode.SetValue <int>(exitCode);
                }

                if (StartTime != null)
                {
                    StartTime.SetValue <DateTime>(process.StartTime);
                }

                if (ExitTime != null)
                {
                    ExitTime.SetValue <DateTime>(process.ExitTime);
                }

                if (ResultConverter == null)
                {
                    return(exitCode == 0);
                }
                else
                {
                    return(ResultConverter.Convert(exitCode));
                }
            }
        }