protected void CreateHelpersForSpecifiedRunspaces()
        {
            int length = this.Session.Length;

            RemoteRunspace[] runspaceArray = new RemoteRunspace[length];
            for (int i = 0; i < length; i++)
            {
                runspaceArray[i] = (RemoteRunspace)this.Session[i].Runspace;
            }
            Pipeline[] pipelineArray = new Pipeline[length];
            for (int j = 0; j < length; j++)
            {
                pipelineArray[j] = this.CreatePipeline(runspaceArray[j]);
                IThrottleOperation item = new ExecutionCmdletHelperRunspace(pipelineArray[j]);
                this.Operations.Add(item);
            }
        }
Beispiel #2
0
        protected void CreateHelpersForSpecifiedRunspaces()
        {
            RemoteRunspace[] remoteRunspaces;
            Pipeline[] pipelines;

            // extract RemoteRunspace out of the PSSession objects
            int length = Session.Length;
            remoteRunspaces = new RemoteRunspace[length];

            for (int i = 0; i < length; i++)
            {
                remoteRunspaces[i] = (RemoteRunspace)Session[i].Runspace;
            }

            // create the set of pipelines from the RemoteRunspace objects and 
            // create IREHelperRunspace helper class to create operations
            pipelines = new Pipeline[length];

            for (int i = 0; i < length; i++)
            {
                pipelines[i] = CreatePipeline(remoteRunspaces[i]);

                // create the operation object
                IThrottleOperation operation = new ExecutionCmdletHelperRunspace(pipelines[i]);
                Operations.Add(operation);
            }
        } // CreateHelpersForSpecifiedRunspaces
Beispiel #3
0
 protected void CreateHelpersForSpecifiedRunspaces()
 {
     int length = this.Session.Length;
     RemoteRunspace[] runspaceArray = new RemoteRunspace[length];
     for (int i = 0; i < length; i++)
     {
         runspaceArray[i] = (RemoteRunspace) this.Session[i].Runspace;
     }
     Pipeline[] pipelineArray = new Pipeline[length];
     for (int j = 0; j < length; j++)
     {
         pipelineArray[j] = this.CreatePipeline(runspaceArray[j]);
         IThrottleOperation item = new ExecutionCmdletHelperRunspace(pipelineArray[j]);
         this.Operations.Add(item);
     }
 }
 protected override void BeginProcessing()
 {
     if (base.InvokeAndDisconnect && this.asjob)
     {
         throw new InvalidOperationException(RemotingErrorIdStrings.AsJobAndDisconnectedError);
     }
     if ((base.InvokeAndDisconnect && ((this.ComputerName == null) || (this.ComputerName.Length == 0))) && ((this.ConnectionUri == null) || (this.ConnectionUri.Length == 0)))
     {
         throw new InvalidOperationException(RemotingErrorIdStrings.InvokeDisconnectedWithoutComputerName);
     }
     if (base.MyInvocation.BoundParameters.ContainsKey("SessionName") && !base.InvokeAndDisconnect)
     {
         throw new InvalidOperationException(RemotingErrorIdStrings.SessionNameWithoutInvokeDisconnected);
     }
     if (base.ParameterSetName.Equals("InProcess"))
     {
         if (this.FilePath != null)
         {
             this.ScriptBlock = base.GetScriptBlockFromFile(this.FilePath, false);
         }
         if (base.MyInvocation.ExpectingInput && !this.ScriptBlock.IsUsingDollarInput())
         {
             try
             {
                 this.steppablePipeline = this.ScriptBlock.GetSteppablePipeline();
                 this.steppablePipeline.Begin(this);
             }
             catch (InvalidOperationException)
             {
             }
         }
     }
     else
     {
         base.BeginProcessing();
         foreach (IThrottleOperation operation in base.Operations)
         {
             this.inputWriters.Add(((ExecutionCmdletHelper)operation).Pipeline.Input);
         }
         if (base.ParameterSetName.Equals("Session"))
         {
             long instanceId = ((LocalRunspace)base.Context.CurrentRunspace).GetCurrentlyRunningPipeline().InstanceId;
             foreach (PSSession session in this.Session)
             {
                 RemoteRunspace runspace = (RemoteRunspace)session.Runspace;
                 if (runspace.IsAnotherInvokeCommandExecuting(this, instanceId))
                 {
                     if (((base.MyInvocation != null) && (base.MyInvocation.PipelinePosition == 1)) && !base.MyInvocation.ExpectingInput)
                     {
                         PSPrimitiveDictionary dictionary = session.ApplicationPrivateData["PSVersionTable"] as PSPrimitiveDictionary;
                         if (dictionary != null)
                         {
                             Version version = dictionary["PSRemotingProtocolVersion"] as Version;
                             if ((version != null) && (version >= RemotingConstants.ProtocolVersionWin8RTM))
                             {
                                 this.needToCollect = false;
                                 this.needToStartSteppablePipelineOnServer = true;
                                 break;
                             }
                         }
                     }
                     this.needToCollect = true;
                     this.needToStartSteppablePipelineOnServer = false;
                     break;
                 }
             }
         }
         if (this.needToStartSteppablePipelineOnServer)
         {
             foreach (IThrottleOperation operation2 in base.Operations)
             {
                 ExecutionCmdletHelperRunspace runspace2 = operation2 as ExecutionCmdletHelperRunspace;
                 if (runspace2 == null)
                 {
                     break;
                 }
                 runspace2.ShouldUseSteppablePipelineOnServer = true;
             }
         }
         else
         {
             this.clearInvokeCommandOnRunspace = true;
         }
         this.DetermineThrowStatementBehavior();
     }
 }