예제 #1
0
파일: Pipe.cs 프로젝트: zuisom/PowerShell
        private void AddToPipe(object obj)
        {
            if (PipelineProcessor != null)
            {
                // Put the pipeline on the notification stack for stop.
                _context.PushPipelineProcessor(PipelineProcessor);
                PipelineProcessor.Step(obj);
                _context.PopPipelineProcessor(false);
            }
            else if (_resultCollection != null)
            {
                _resultCollection.Add(obj != null ? PSObject.AsPSObject(obj) : null);
            }
            else if (_resultList != null)
            {
                _resultList.Add(obj);
            }
            else if (_externalWriter != null)
            {
                _externalWriter.Write(obj);
            }
            else if (ObjectQueue != null)
            {
                ObjectQueue.Enqueue(obj);

                // This is the "streamlet" recursive call
                if (_downstreamCmdlet != null && ObjectQueue.Count > OutBufferCount)
                {
                    _downstreamCmdlet.DoExecute();
                }
            }
        }
예제 #2
0
        private void Inject(object input, bool enumerate)
        {
            CommandProcessorBase base2 = this._commands[0];

            if ((base2 == null) || (base2.CommandRuntime == null))
            {
                throw PSTraceSource.NewInvalidOperationException("PipelineStrings", "PipelineExecuteRequiresAtLeastOneCommand", new object[0]);
            }
            if (input != AutomationNull.Value)
            {
                if (enumerate)
                {
                    IEnumerator enumeratorToProcess = LanguagePrimitives.GetEnumerator(input);
                    if (enumeratorToProcess != null)
                    {
                        base2.CommandRuntime.InputPipe = new Pipe(enumeratorToProcess);
                    }
                    else
                    {
                        base2.CommandRuntime.InputPipe.Add(input);
                    }
                }
                else
                {
                    base2.CommandRuntime.InputPipe.Add(input);
                }
            }
            base2.DoExecute();
        }