示例#1
0
 internal RemoteRunspace(TypeTable typeTable, RunspaceConnectionInfo connectionInfo, PSHost host, PSPrimitiveDictionary applicationArguments, string name = null, int id = -1)
 {
     this._runningPipelines   = new ArrayList();
     this._syncRoot           = new object();
     this._runspaceStateInfo  = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen);
     this._version            = PSVersionInfo.PSVersion;
     this._runspaceEventQueue = new Queue <RunspaceEventQueueItem>();
     this.id = -1;
     PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId);
     this._applicationArguments = applicationArguments;
     PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() });
     if (connectionInfo is WSManConnectionInfo)
     {
         this._connectionInfo         = ((WSManConnectionInfo)connectionInfo).Copy();
         this._originalConnectionInfo = ((WSManConnectionInfo)connectionInfo).Copy();
     }
     else if (connectionInfo is NewProcessConnectionInfo)
     {
         this._connectionInfo         = ((NewProcessConnectionInfo)connectionInfo).Copy();
         this._originalConnectionInfo = ((NewProcessConnectionInfo)connectionInfo).Copy();
     }
     this._runspacePool = new System.Management.Automation.Runspaces.RunspacePool(1, 1, typeTable, host, applicationArguments, connectionInfo, name);
     this.Id            = id;
     this.SetEventHandlers();
 }
示例#2
0
        internal RemoteRunspace(TypeTable typeTable, RunspaceConnectionInfo connectionInfo, PSHost host, PSPrimitiveDictionary applicationArguments, string name = null, int id = -1)
        {
            this._runningPipelines = new ArrayList();
            this._syncRoot = new object();
            this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen);
            this._version = PSVersionInfo.PSVersion;
            this._runspaceEventQueue = new Queue<RunspaceEventQueueItem>();
            this.id = -1;
            PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId);
			this._applicationArguments = applicationArguments;
            PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() });
            if (connectionInfo is WSManConnectionInfo)
            {
                this._connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy();
                this._originalConnectionInfo = ((WSManConnectionInfo) connectionInfo).Copy();
            }
            else if (connectionInfo is NewProcessConnectionInfo)
            {
                this._connectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy();
                this._originalConnectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy();
            }
            this._runspacePool = new System.Management.Automation.Runspaces.RunspacePool(1, 1, typeTable, host, applicationArguments, connectionInfo, name);
            this.Id = id;
            this.SetEventHandlers();
        }
示例#3
0
 private void SetRunspaceState(RunspaceState state, Exception reason)
 {
     lock (this._syncRoot)
     {
         if (state != this._runspaceStateInfo.State)
         {
             this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(state, reason);
             System.Management.Automation.Runspaces.RunspaceAvailability currentAvailability = this._runspaceAvailability;
             base.UpdateRunspaceAvailability(this._runspaceStateInfo.State, false);
             this._runspaceEventQueue.Enqueue(new RunspaceEventQueueItem(this._runspaceStateInfo.Clone(), currentAvailability, this._runspaceAvailability));
             PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceStateChange, PSOpcode.Open, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { state.ToString() });
         }
     }
 }
示例#4
0
 internal RemoteRunspace(System.Management.Automation.Runspaces.RunspacePool runspacePool)
 {
     this._runningPipelines   = new ArrayList();
     this._syncRoot           = new object();
     this._runspaceStateInfo  = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen);
     this._version            = PSVersionInfo.PSVersion;
     this._runspaceEventQueue = new Queue <RunspaceEventQueueItem>();
     this.id = -1;
     if ((runspacePool.RunspacePoolStateInfo.State != RunspacePoolState.Disconnected) || !(runspacePool.ConnectionInfo is WSManConnectionInfo))
     {
         throw PSTraceSource.NewInvalidOperationException("RunspaceStrings", "InvalidRunspacePool", new object[0]);
     }
     this._runspacePool = runspacePool;
     this._runspacePool.RemoteRunspacePoolInternal.SetMinRunspaces(1);
     this._runspacePool.RemoteRunspacePoolInternal.SetMaxRunspaces(1);
     this._connectionInfo = ((WSManConnectionInfo)runspacePool.ConnectionInfo).Copy();
     this.SetRunspaceState(RunspaceState.Disconnected, null);
     this._runspaceAvailability = this._runspacePool.RemoteRunspacePoolInternal.AvailableForConnection ? System.Management.Automation.Runspaces.RunspaceAvailability.None : System.Management.Automation.Runspaces.RunspaceAvailability.Busy;
     this.SetEventHandlers();
     PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId);
     PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() });
 }
示例#5
0
 internal RemoteRunspace(System.Management.Automation.Runspaces.RunspacePool runspacePool)
 {
     this._runningPipelines = new ArrayList();
     this._syncRoot = new object();
     this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen);
     this._version = PSVersionInfo.PSVersion;
     this._runspaceEventQueue = new Queue<RunspaceEventQueueItem>();
     this.id = -1;
     if ((runspacePool.RunspacePoolStateInfo.State != RunspacePoolState.Disconnected) || !(runspacePool.ConnectionInfo is WSManConnectionInfo))
     {
         throw PSTraceSource.NewInvalidOperationException("RunspaceStrings", "InvalidRunspacePool", new object[0]);
     }
     this._runspacePool = runspacePool;
     this._runspacePool.RemoteRunspacePoolInternal.SetMinRunspaces(1);
     this._runspacePool.RemoteRunspacePoolInternal.SetMaxRunspaces(1);
     this._connectionInfo = ((WSManConnectionInfo) runspacePool.ConnectionInfo).Copy();
     this.SetRunspaceState(RunspaceState.Disconnected, null);
     this._runspaceAvailability = this._runspacePool.RemoteRunspacePoolInternal.AvailableForConnection ? System.Management.Automation.Runspaces.RunspaceAvailability.None : System.Management.Automation.Runspaces.RunspaceAvailability.Busy;
     this.SetEventHandlers();
     PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId);
     PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() });
 }
示例#6
0
 internal RunspaceStateInfo(RunspaceStateInfo runspaceStateInfo)
 {
     this._state  = runspaceStateInfo.State;
     this._reason = runspaceStateInfo.Reason;
 }
示例#7
0
 /// <summary>
 /// Constructs RunspaceStateEventArgs using RunspaceStateInfo
 /// </summary>
 /// <param name="runspaceStateInfo">The information about 
 /// current state of the runspace.</param>
 /// <exception cref="ArgumentNullException">runspaceStateInfo is null
 /// </exception>
 internal RunspaceStateEventArgs(RunspaceStateInfo runspaceStateInfo)
 {
     if (runspaceStateInfo == null)
     {
         throw PSTraceSource.NewArgumentNullException("runspaceStateInfo");
     }
     RunspaceStateInfo = runspaceStateInfo;
 }
示例#8
0
 /// <summary>
 /// Copy constructor to support cloning.
 /// </summary>
 /// <param name="runspaceStateInfo">The source 
 /// RunspaceStateInfo
 /// </param>
 internal RunspaceStateInfo(RunspaceStateInfo runspaceStateInfo)
 {
     State = runspaceStateInfo.State;
     Reason = runspaceStateInfo.Reason;
 }
示例#9
0
        /// <summary>
        /// Set the new runspace state.
        /// </summary>
        /// <param name="state">the new state</param>
        /// <param name="reason">An exception indicating the state change is the 
        /// result of an error, otherwise; null.
        /// </param>
        /// <remarks>
        /// Sets the internal runspace state information member variable. It also 
        /// adds RunspaceStateInfo to a queue. 
        /// RaiseRunspaceStateEvents raises event for each item in this queue.
        /// </remarks>        
        protected void SetRunspaceState(RunspaceState state, Exception reason)
        {
            lock (SyncRoot)
            {
                if (state != RunspaceState)
                {
                    _runspaceStateInfo = new RunspaceStateInfo(state, reason);

                    //Add _runspaceStateInfo to _runspaceEventQueue.
                    //RaiseRunspaceStateEvents will raise event for each item
                    //in this queue.
                    //Note:We are doing clone here instead of passing the member 
                    //_runspaceStateInfo because we donot want outside
                    //to change our runspace state.
                    RunspaceAvailability previousAvailability = _runspaceAvailability;

                    this.UpdateRunspaceAvailability(_runspaceStateInfo.State, false);

                    _runspaceEventQueue.Enqueue(
                        new RunspaceEventQueueItem(
                            _runspaceStateInfo.Clone(),
                            previousAvailability,
                            _runspaceAvailability));
                }
            }
        }
示例#10
0
 public RunspaceEventQueueItem(RunspaceStateInfo runspaceStateInfo, RunspaceAvailability currentAvailability, RunspaceAvailability newAvailability)
 {
     this.RunspaceStateInfo = runspaceStateInfo;
     this.CurrentRunspaceAvailability = currentAvailability;
     this.NewRunspaceAvailability = newAvailability;
 }
示例#11
0
 internal RunspaceStateInfo(RunspaceStateInfo runspaceStateInfo)
 {
     this._state = runspaceStateInfo.State;
     this._reason = runspaceStateInfo.Reason;
 }
示例#12
0
 public RunspaceEventQueueItem(System.Management.Automation.Runspaces.RunspaceStateInfo runspaceStateInfo, RunspaceAvailability currentAvailability, RunspaceAvailability newAvailability)
 {
     this.RunspaceStateInfo           = runspaceStateInfo;
     this.CurrentRunspaceAvailability = currentAvailability;
     this.NewRunspaceAvailability     = newAvailability;
 }
示例#13
0
        /// <summary>
        /// Set the new runspace state.
        /// </summary>
        /// <param name="state">the new state</param>
        /// <param name="reason">An exception indicating the state change is the 
        /// result of an error, otherwise; null.
        /// </param>
        /// <returns>Previous runspace state</returns>
        /// <remarks>
        /// Sets the internal runspace state information member variable. It also 
        /// adds RunspaceStateInfo to a queue. 
        /// RaiseRunspaceStateEvents raises event for each item in this queue.
        /// </remarks>
        private RunspaceState SetRunspaceState(RunspaceState state, Exception reason)
        {
            RunspaceState prevState;

            lock (_syncRoot)
            {
                prevState = _runspaceStateInfo.State;
                if (state != prevState)
                {
                    _runspaceStateInfo = new RunspaceStateInfo(state, reason);

                    //Add _runspaceStateInfo to _runspaceEventQueue. 
                    //RaiseRunspaceStateEvents will raise event for each item
                    //in this queue.
                    //Note:We are doing clone here instead of passing the member 
                    //_runspaceStateInfo because we donot want outside
                    //to change our runspace state.
                    RunspaceAvailability previousAvailability = _runspaceAvailability;

                    this.UpdateRunspaceAvailability(_runspaceStateInfo.State, false);

                    _runspaceEventQueue.Enqueue(
                        new RunspaceEventQueueItem(
                            _runspaceStateInfo.Clone(),
                            previousAvailability,
                            _runspaceAvailability));

                    PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceStateChange, PSOpcode.Open,
                                PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational,
                                state.ToString());
                }
            }

            return prevState;
        }
示例#14
0
 public RunspaceEventQueueItem(System.Management.Automation.Runspaces.RunspaceStateInfo runspaceStateInfo, RunspaceAvailability currentAvailability, RunspaceAvailability newAvailability)
 {
     this.RunspaceStateInfo = runspaceStateInfo;
     this.CurrentRunspaceAvailability = currentAvailability;
     this.NewRunspaceAvailability = newAvailability;
 }
示例#15
0
 private void SetRunspaceState(RunspaceState state, Exception reason)
 {
     lock (this._syncRoot)
     {
         if (state != this._runspaceStateInfo.State)
         {
             this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(state, reason);
             System.Management.Automation.Runspaces.RunspaceAvailability currentAvailability = this._runspaceAvailability;
             base.UpdateRunspaceAvailability(this._runspaceStateInfo.State, false);
             this._runspaceEventQueue.Enqueue(new RunspaceEventQueueItem(this._runspaceStateInfo.Clone(), currentAvailability, this._runspaceAvailability));
             PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceStateChange, PSOpcode.Open, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { state.ToString() });
         }
     }
 }