예제 #1
0
 private void OnStateChanged(object source, RunspacePoolStateChangedEventArgs args)
 {
     if (this.InternalStateChanged == null)
     {
         return;
     }
     this.InternalStateChanged((object)this, args);
 }
예제 #2
0
 private void OnStateChanged(object source, RunspacePoolStateChangedEventArgs args)
 {
     if (this.ConnectionInfo is NewProcessConnectionInfo)
     {
         NewProcessConnectionInfo connectionInfo = this.ConnectionInfo as NewProcessConnectionInfo;
         if ((connectionInfo.Process != null) && ((args.RunspacePoolStateInfo.State == RunspacePoolState.Opened) || (args.RunspacePoolStateInfo.State == RunspacePoolState.Broken)))
         {
             connectionInfo.Process.RunspacePool = this;
         }
     }
     this.InternalStateChanged.SafeInvoke <RunspacePoolStateChangedEventArgs>(this, args);
 }
예제 #3
0
        /// <summary>
        /// Handle internal Pool state changed events.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        private void OnStateChanged(object source, RunspacePoolStateChangedEventArgs args)
        {
            if (ConnectionInfo is NewProcessConnectionInfo)
            {
                NewProcessConnectionInfo connectionInfo = ConnectionInfo as NewProcessConnectionInfo;
                if (connectionInfo.Process != null &&
                    (args.RunspacePoolStateInfo.State == RunspacePoolState.Opened ||
                     args.RunspacePoolStateInfo.State == RunspacePoolState.Broken))
                {
                    connectionInfo.Process.RunspacePool = this;
                }
            }

            // call any event handlers on this, replacing the
            // internalPool sender with 'this' since receivers
            // are expecting a RunspacePool
            InternalStateChanged.SafeInvoke(this, args);
        }
예제 #4
0
        /// <summary>
        /// handler to the runspace pool state changed events
        /// </summary>
        /// <param name="sender">sender of this events</param>
        /// <param name="eventArgs">arguments which describe the
        /// RunspacePool's StateChanged event</param>
        private void HandleRunspacePoolStateChanged(object sender,
                            RunspacePoolStateChangedEventArgs eventArgs)
        {
            RunspacePoolState state = eventArgs.RunspacePoolStateInfo.State;
            Exception reason = eventArgs.RunspacePoolStateInfo.Reason;

            switch (state)
            {
                case RunspacePoolState.Broken:
                case RunspacePoolState.Closing:
                case RunspacePoolState.Closed:
                    {
                        DataStructureHandler.SendStateInfoToClient(new RunspacePoolStateInfo(state, reason));
                    }
                    break;

                case RunspacePoolState.Opened:
                    {
                        SendApplicationPrivateDataToClient();
                        DataStructureHandler.SendStateInfoToClient(new RunspacePoolStateInfo(state, reason));
                    }
                    break;
            }
        }
예제 #5
0
 private void OnStateChanged(object source, RunspacePoolStateChangedEventArgs args)
 {
     if (this.ConnectionInfo is NewProcessConnectionInfo)
     {
         NewProcessConnectionInfo connectionInfo = this.ConnectionInfo as NewProcessConnectionInfo;
         if ((connectionInfo.Process != null) && ((args.RunspacePoolStateInfo.State == RunspacePoolState.Opened) || (args.RunspacePoolStateInfo.State == RunspacePoolState.Broken)))
         {
             connectionInfo.Process.RunspacePool = this;
         }
     }
     this.InternalStateChanged.SafeInvoke<RunspacePoolStateChangedEventArgs>(this, args);
 }
예제 #6
0
        /// <summary>
        /// Handle internal Pool state changed events.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        private void OnStateChanged(object source, RunspacePoolStateChangedEventArgs args)
        {
            if (ConnectionInfo is NewProcessConnectionInfo)
            {
                NewProcessConnectionInfo connectionInfo = ConnectionInfo as NewProcessConnectionInfo;
                if (connectionInfo.Process != null &&
                    (args.RunspacePoolStateInfo.State == RunspacePoolState.Opened ||
                     args.RunspacePoolStateInfo.State == RunspacePoolState.Broken))
                {
                    connectionInfo.Process.RunspacePool = this;
                }
            }

            // call any event handlers on this, replacing the 
            // internalPool sender with 'this' since receivers
            // are expecting a RunspacePool
            InternalStateChanged.SafeInvoke(this, args);
        }
예제 #7
0
        private void HandleRunspacePoolStateChanged(object sender, RunspacePoolStateChangedEventArgs e)
        {
            RunspaceState newState = (RunspaceState)e.RunspacePoolStateInfo.State;

            RunspaceState prevState = SetRunspaceState(newState, e.RunspacePoolStateInfo.Reason);

            switch (newState)
            {
                case RunspaceState.Opened:
                    switch (prevState)
                    {
                        case RunspaceState.Opening:
                            // For newly opened remote runspaces, set the debug mode based on the 
                            // associated host.  This involves running a remote command and is Ok
                            // since this event is called on a worker thread and not a WinRM callback.
                            SetDebugModeOnOpen();
                            break;

                        case RunspaceState.Connecting:
                            UpdateDisconnectExpiresOn();

                            // Application private data containing server debug state is updated on
                            // a *reconstruct* connect operation when _applicationPrivateData is null.  
                            // Pass new information to the debugger.
                            if (_applicationPrivateData == null)
                            {
                                _applicationPrivateData = GetApplicationPrivateData();
                                SetDebugInfo(_applicationPrivateData);
                            }
                            break;
                    }
                    break;

                case RunspaceState.Disconnected:
                    UpdateDisconnectExpiresOn();
                    break;
            }

            RaiseRunspaceStateEvents();
        }
예제 #8
0
 private void HandleRunspacePoolStateChanged(object sender, RunspacePoolStateChangedEventArgs e)
 {
     this.SetRunspaceState((RunspaceState) e.RunspacePoolStateInfo.State, e.RunspacePoolStateInfo.Reason);
     this.RaiseRunspaceStateEvents();
 }