internal ServerSteppablePipelineDriver(PowerShell powershell, bool noInput, Guid clientPowerShellId, Guid clientRunspacePoolId, ServerRunspacePoolDriver runspacePoolDriver, ApartmentState apartmentState, HostInfo hostInfo, System.Management.Automation.RemoteStreamOptions streamOptions, bool addToHistory, Runspace rsToUse, ServerSteppablePipelineSubscriber eventSubscriber, PSDataCollection<object> powershellInput)
 {
     this.localPowerShell = powershell;
     this.clientPowerShellId = clientPowerShellId;
     this.clientRunspacePoolId = clientRunspacePoolId;
     this.remoteStreamOptions = streamOptions;
     this.apartmentState = apartmentState;
     this.noInput = noInput;
     this.addToHistory = addToHistory;
     this.eventSubscriber = eventSubscriber;
     this.powershellInput = powershellInput;
     this.input = new PSDataCollection<object>();
     this.inputEnumerator = this.input.GetEnumerator();
     this.input.ReleaseOnEnumeration = true;
     this.dsHandler = runspacePoolDriver.DataStructureHandler.CreatePowerShellDataStructureHandler(clientPowerShellId, clientRunspacePoolId, this.remoteStreamOptions, null);
     this.remoteHost = this.dsHandler.GetHostAssociatedWithPowerShell(hostInfo, runspacePoolDriver.ServerRemoteHost);
     this.dsHandler.InputEndReceived += new EventHandler(this.HandleInputEndReceived);
     this.dsHandler.InputReceived += new EventHandler<RemoteDataEventArgs<object>>(this.HandleInputReceived);
     this.dsHandler.StopPowerShellReceived += new EventHandler(this.HandleStopReceived);
     this.dsHandler.HostResponseReceived += new EventHandler<RemoteDataEventArgs<RemoteHostResponse>>(this.HandleHostResponseReceived);
     this.dsHandler.OnSessionConnected += new EventHandler(this.HandleSessionConnected);
     if (rsToUse == null)
     {
         throw PSTraceSource.NewInvalidOperationException("RemotingErrorIdStrings", "NestedPipelineMissingRunspace", new object[0]);
     }
     this.localPowerShell.Runspace = rsToUse;
     eventSubscriber.SubscribeEvents(this);
     this.stateOfSteppablePipeline = PSInvocationState.NotStarted;
 }
예제 #2
0
 internal ServerSteppablePipelineDriver(PowerShell powershell, bool noInput, Guid clientPowerShellId, Guid clientRunspacePoolId, ServerRunspacePoolDriver runspacePoolDriver, ApartmentState apartmentState, HostInfo hostInfo, System.Management.Automation.RemoteStreamOptions streamOptions, bool addToHistory, Runspace rsToUse, ServerSteppablePipelineSubscriber eventSubscriber, PSDataCollection <object> powershellInput)
 {
     this.localPowerShell      = powershell;
     this.clientPowerShellId   = clientPowerShellId;
     this.clientRunspacePoolId = clientRunspacePoolId;
     this.remoteStreamOptions  = streamOptions;
     this.apartmentState       = apartmentState;
     this.noInput                           = noInput;
     this.addToHistory                      = addToHistory;
     this.eventSubscriber                   = eventSubscriber;
     this.powershellInput                   = powershellInput;
     this.input                             = new PSDataCollection <object>();
     this.inputEnumerator                   = this.input.GetEnumerator();
     this.input.ReleaseOnEnumeration        = true;
     this.dsHandler                         = runspacePoolDriver.DataStructureHandler.CreatePowerShellDataStructureHandler(clientPowerShellId, clientRunspacePoolId, this.remoteStreamOptions, null);
     this.remoteHost                        = this.dsHandler.GetHostAssociatedWithPowerShell(hostInfo, runspacePoolDriver.ServerRemoteHost);
     this.dsHandler.InputEndReceived       += new EventHandler(this.HandleInputEndReceived);
     this.dsHandler.InputReceived          += new EventHandler <RemoteDataEventArgs <object> >(this.HandleInputReceived);
     this.dsHandler.StopPowerShellReceived += new EventHandler(this.HandleStopReceived);
     this.dsHandler.HostResponseReceived   += new EventHandler <RemoteDataEventArgs <RemoteHostResponse> >(this.HandleHostResponseReceived);
     this.dsHandler.OnSessionConnected     += new EventHandler(this.HandleSessionConnected);
     if (rsToUse == null)
     {
         throw PSTraceSource.NewInvalidOperationException("RemotingErrorIdStrings", "NestedPipelineMissingRunspace", new object[0]);
     }
     this.localPowerShell.Runspace = rsToUse;
     eventSubscriber.SubscribeEvents(this);
     this.stateOfSteppablePipeline = PSInvocationState.NotStarted;
 }
예제 #3
0
 internal ServerPowerShellDriver(PowerShell powershell, PowerShell extraPowerShell, bool noInput, Guid clientPowerShellId, Guid clientRunspacePoolId, ServerRunspacePoolDriver runspacePoolDriver, ApartmentState apartmentState, HostInfo hostInfo, System.Management.Automation.RemoteStreamOptions streamOptions, bool addToHistory, Runspace rsToUse)
 {
     this.clientPowerShellId    = clientPowerShellId;
     this.clientRunspacePoolId  = clientRunspacePoolId;
     this.remoteStreamOptions   = streamOptions;
     this.apartmentState        = apartmentState;
     this.localPowerShell       = powershell;
     this.extraPowerShell       = extraPowerShell;
     this.localPowerShellOutput = new PSDataCollection <PSObject>();
     this.noInput      = noInput;
     this.addToHistory = addToHistory;
     this.dsHandler    = runspacePoolDriver.DataStructureHandler.CreatePowerShellDataStructureHandler(clientPowerShellId, clientRunspacePoolId, this.remoteStreamOptions, this.localPowerShell);
     this.remoteHost   = this.dsHandler.GetHostAssociatedWithPowerShell(hostInfo, runspacePoolDriver.ServerRemoteHost);
     if (!noInput)
     {
         this.input = new PSDataCollection <object>();
         this.input.ReleaseOnEnumeration = true;
         this.input.IdleEvent           += new EventHandler <EventArgs>(this.HandleIdleEvent);
     }
     this.RegisterPipelineOutputEventHandlers(this.localPowerShellOutput);
     if (this.localPowerShell != null)
     {
         this.RegisterPowerShellEventHandlers(this.localPowerShell);
         this.datasent[0] = false;
     }
     if (extraPowerShell != null)
     {
         this.RegisterPowerShellEventHandlers(extraPowerShell);
         this.datasent[1] = false;
     }
     this.RegisterDataStructureHandlerEventHandlers(this.dsHandler);
     if (rsToUse != null)
     {
         this.localPowerShell.Runspace = rsToUse;
         if (extraPowerShell != null)
         {
             extraPowerShell.Runspace = rsToUse;
         }
     }
     else
     {
         this.localPowerShell.RunspacePool = runspacePoolDriver.RunspacePool;
         if (extraPowerShell != null)
         {
             extraPowerShell.RunspacePool = runspacePoolDriver.RunspacePool;
         }
     }
 }
예제 #4
0
 internal ServerPowerShellDriver(PowerShell powershell, PowerShell extraPowerShell, bool noInput, Guid clientPowerShellId, Guid clientRunspacePoolId, ServerRunspacePoolDriver runspacePoolDriver, ApartmentState apartmentState, HostInfo hostInfo, System.Management.Automation.RemoteStreamOptions streamOptions, bool addToHistory, Runspace rsToUse)
 {
     this.clientPowerShellId = clientPowerShellId;
     this.clientRunspacePoolId = clientRunspacePoolId;
     this.remoteStreamOptions = streamOptions;
     this.apartmentState = apartmentState;
     this.localPowerShell = powershell;
     this.extraPowerShell = extraPowerShell;
     this.localPowerShellOutput = new PSDataCollection<PSObject>();
     this.noInput = noInput;
     this.addToHistory = addToHistory;
     this.dsHandler = runspacePoolDriver.DataStructureHandler.CreatePowerShellDataStructureHandler(clientPowerShellId, clientRunspacePoolId, this.remoteStreamOptions, this.localPowerShell);
     this.remoteHost = this.dsHandler.GetHostAssociatedWithPowerShell(hostInfo, runspacePoolDriver.ServerRemoteHost);
     if (!noInput)
     {
         this.input = new PSDataCollection<object>();
         this.input.ReleaseOnEnumeration = true;
         this.input.IdleEvent += new EventHandler<EventArgs>(this.HandleIdleEvent);
     }
     this.RegisterPipelineOutputEventHandlers(this.localPowerShellOutput);
     if (this.localPowerShell != null)
     {
         this.RegisterPowerShellEventHandlers(this.localPowerShell);
         this.datasent[0] = false;
     }
     if (extraPowerShell != null)
     {
         this.RegisterPowerShellEventHandlers(extraPowerShell);
         this.datasent[1] = false;
     }
     this.RegisterDataStructureHandlerEventHandlers(this.dsHandler);
     if (rsToUse != null)
     {
         this.localPowerShell.Runspace = rsToUse;
         if (extraPowerShell != null)
         {
             extraPowerShell.Runspace = rsToUse;
         }
     }
     else
     {
         this.localPowerShell.RunspacePool = runspacePoolDriver.RunspacePool;
         if (extraPowerShell != null)
         {
             extraPowerShell.RunspacePool = runspacePoolDriver.RunspacePool;
         }
     }
 }