示例#1
0
        /// <summary>
        /// Create a Pipeline with an existing command string.
        /// Caller should validate all the parameters.
        /// </summary>
        /// <param name="runspace">
        /// The LocalRunspace to associate with this pipeline.
        /// </param>
        /// <param name="command">
        /// The command to invoke.
        /// </param>
        /// <param name="addToHistory">
        /// If true, add the command to history.
        /// </param>
        /// <param name="isNested">
        /// If true, mark this pipeline as a nested pipeline.
        /// </param>
        /// <param name="inputStream">
        /// Stream to use for reading input objects.
        /// </param>
        /// <param name="errorStream">
        /// Stream to use for writing error objects.
        /// </param>
        /// <param name="outputStream">
        /// Stream to use for writing output objects.
        /// </param>
        /// <param name="infoBuffers">
        /// Buffers used to write progress, verbose, debug, warning, information
        /// information of an invocation.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Command is null and add to history is true
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// 1. InformationalBuffers is null
        /// </exception>
        protected PipelineBase(Runspace runspace,
                               CommandCollection command,
                               bool addToHistory,
                               bool isNested,
                               ObjectStreamBase inputStream,
                               ObjectStreamBase outputStream,
                               ObjectStreamBase errorStream,
                               PSInformationalBuffers infoBuffers)
            : base(runspace, command)
        {
            Dbg.Assert(inputStream != null, "Caller Should validate inputstream parameter");
            Dbg.Assert(outputStream != null, "Caller Should validate outputStream parameter");
            Dbg.Assert(errorStream != null, "Caller Should validate errorStream parameter");
            Dbg.Assert(infoBuffers != null, "Caller Should validate informationalBuffers parameter");
            Dbg.Assert(command != null, "Command cannot be null");

            // Since we are constructing this pipeline using a commandcollection we dont need
            // to add cmd to CommandCollection again (Initialize does this).. because of this
            // I am handling history here..
            Initialize(runspace, null, false, isNested);
            if (addToHistory)
            {
                // get command text for history..
                string cmdText = command.GetCommandStringForHistory();
                HistoryString = cmdText;
                AddToHistory  = addToHistory;
            }

            // Initialize streams
            InputStream          = inputStream;
            OutputStream         = outputStream;
            ErrorStream          = errorStream;
            InformationalBuffers = infoBuffers;
        }
示例#2
0
 protected PipelineBase(
     Runspace runspace,
     CommandCollection command,
     bool addToHistory,
     bool isNested,
     ObjectStreamBase inputStream,
     ObjectStreamBase outputStream,
     ObjectStreamBase errorStream,
     PSInformationalBuffers infoBuffers)
     : base(runspace, command)
 {
     using (PipelineBase._trace.TraceConstructor((object)this))
     {
         this.Initialize(runspace, (string)null, false, isNested);
         if (addToHistory)
         {
             this._historyString = command.GetCommandStringForHistory();
             this._addToHistory  = addToHistory;
         }
         this._inputStream          = inputStream;
         this._outputStream         = outputStream;
         this._errorStream          = errorStream;
         this._informationalBuffers = infoBuffers;
     }
 }
示例#3
0
 protected PipelineBase(System.Management.Automation.Runspaces.Runspace runspace, CommandCollection command, bool addToHistory, bool isNested, ObjectStreamBase inputStream, ObjectStreamBase outputStream, ObjectStreamBase errorStream, PSInformationalBuffers infoBuffers) : base(runspace, command)
 {
     this._pipelineStateInfo   = new System.Management.Automation.Runspaces.PipelineStateInfo(System.Management.Automation.Runspaces.PipelineState.NotStarted);
     this._performNestedCheck  = true;
     this._executionEventQueue = new Queue <ExecutionEventQueueItem>();
     this._syncRoot            = new object();
     this.Initialize(runspace, null, false, isNested);
     if (addToHistory)
     {
         string commandStringForHistory = command.GetCommandStringForHistory();
         this._historyString = commandStringForHistory;
         this._addToHistory  = addToHistory;
     }
     this._inputStream          = inputStream;
     this._outputStream         = outputStream;
     this._errorStream          = errorStream;
     this._informationalBuffers = infoBuffers;
 }