Esempio n. 1
0
        void PollForResults(bool drainQueues = false)
        {
            ShouldProcessPrompt process;

            while (_process.TryDequeue(out process))
            {
                process.Completer.TrySetResult(CommandRuntime.ShouldProcess(process.Target, process.Message));
            }

            ShouldContinuePrompt shouldContinue;

            while (_continue.TryDequeue(out shouldContinue))
            {
                shouldContinue.Completer.TrySetResult(CommandRuntime.ShouldContinue(shouldContinue.Query, shouldContinue.Caption));
            }

            ErrorRecord exception;

            while (_error.TryDequeue(out exception))
            {
                CommandRuntime.WriteError(exception);
            }

            CmdletOutput output;

            while (_output.TryDequeue(out output))
            {
                CommandRuntime.WriteObject(output.Output, output.Enumerate);
            }

            string logMessage;

            while (_warning.TryDequeue(out logMessage))
            {
                CommandRuntime.WriteWarning(logMessage);
            }

            while (_verbose.TryDequeue(out logMessage))
            {
                CommandRuntime.WriteVerbose(logMessage);
            }

            while (_debug.TryDequeue(out logMessage))
            {
                CommandRuntime.WriteDebug(logMessage);
            }

            ProgressRecord progress;

            while (_progress.TryDequeue(out progress))
            {
                CommandRuntime.WriteProgress(progress);
            }

            foreach (var progressItem in _progressTasks.Keys)
            {
                ReportTaskProgress(progressItem);
            }
        }
Esempio n. 2
0
 public void WriteObject(object sendToPipeline)
 {
     if (CommandRuntime == null)
     {
         throw new NotImplementedException("WriteObject");
     }
     CommandRuntime.WriteObject(sendToPipeline);
 }
Esempio n. 3
0
 public void WriteObject(object sendToPipeline, bool enumerateCollection)
 {
     if (CommandRuntime == null)
     {
         throw new NotImplementedException("WriteObject");
     }
     CommandRuntime.WriteObject(sendToPipeline, enumerateCollection);
 }
Esempio n. 4
0
        internal override void ProcessRecord()
        {
            if (!_shouldBlock)
            {
                return;
            }

            if (!ExecutionContext.WriteSideEffectsToPipeline)
            {
                // TODO: Ctrl-C cancellation?
                _process.WaitForExit();
                return;
            }

            var output = _process.StandardOutput;

            while (!output.EndOfStream)
            {
                var line = output.ReadLine();
                CommandRuntime.WriteObject(line);
            }
        }
Esempio n. 5
0
        public override void ProcessRecords()
        {
            // TODO: make a check if process is already started. ProcessRecords() can be called multiple times
            var flag = GetPSForceSynchronizeProcessOutput();

            _shouldBlock = NeedWaitForProcess(flag, ApplicationInfo.Path);
            _process     = StartProcess();

            foreach (var curInput in CommandRuntime.InputStream.Read())
            {
                if (curInput != null)
                {
                    _process.StandardInput.WriteLine(curInput.ToString());
                }
            }

            if (!_shouldBlock)
            {
                return;
            }

            if (!ExecutionContext.WriteSideEffectsToPipeline)
            {
                // TODO: Ctrl-C cancellation?
                _process.WaitForExit();
                return;
            }

            var output = _process.StandardOutput;

            while (!output.EndOfStream)
            {
                var line = output.ReadLine();
                CommandRuntime.WriteObject(line);
            }
        }