Exemplo n.º 1
0
        /// <summary>
        /// Constructor for ServerRemoteHost.
        /// </summary>
        internal ServerRemoteHost(
            Guid clientRunspacePoolId,
            Guid clientPowerShellId,
            HostInfo hostInfo,
            AbstractServerTransportManager transportManager,
            Runspace runspace,
            ServerDriverRemoteHost serverDriverRemoteHost)
        {
            _clientRunspacePoolId = clientRunspacePoolId;
            _clientPowerShellId   = clientPowerShellId;
            Dbg.Assert(hostInfo != null, "Expected hostInfo != null");
            Dbg.Assert(transportManager != null, "Expected transportManager != null");

            // Set host-info and the transport-manager.
            HostInfo                = hostInfo;
            _transportManager       = transportManager;
            _serverDriverRemoteHost = serverDriverRemoteHost;

            // Create the executor for the host methods.
            _serverMethodExecutor = new ServerMethodExecutor(
                clientRunspacePoolId, clientPowerShellId, _transportManager);

            // Use HostInfo to create host-UI as null or non-null based on the client's host-UI.
            _remoteHostUserInterface = hostInfo.IsHostUINull ? null : new ServerRemoteHostUserInterface(this);

            Runspace = runspace;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for ServerRemoteHost.
        /// </summary>
        internal ServerRemoteHost(
            Guid clientRunspacePoolId,
            Guid clientPowerShellId,
            HostInfo hostInfo,
            AbstractServerTransportManager transportManager,
            Runspace runspace,
            ServerDriverRemoteHost serverDriverRemoteHost)
        {
            _clientRunspacePoolId = clientRunspacePoolId;
            _clientPowerShellId = clientPowerShellId;
            Dbg.Assert(hostInfo != null, "Expected hostInfo != null");
            Dbg.Assert(transportManager != null, "Expected transportManager != null");

            // Set host-info and the transport-manager.
            HostInfo = hostInfo;
            _transportManager = transportManager;
            _serverDriverRemoteHost = serverDriverRemoteHost;

            // Create the executor for the host methods.
            _serverMethodExecutor = new ServerMethodExecutor(
                clientRunspacePoolId, clientPowerShellId, _transportManager);

            // Use HostInfo to create host-UI as null or non-null based on the client's host-UI.
            _remoteHostUserInterface = hostInfo.IsHostUINull ? null : new ServerRemoteHostUserInterface(this);

            Runspace = runspace;
        }
Exemplo n.º 3
0
 internal ServerMethodExecutor(Guid clientRunspacePoolId, Guid clientPowerShellId, AbstractServerTransportManager transportManager)
 {
     this._clientRunspacePoolId   = clientRunspacePoolId;
     this._clientPowerShellId     = clientPowerShellId;
     this._transportManager       = transportManager;
     this._remoteHostCallDataType = (clientPowerShellId == Guid.Empty) ? RemotingDataType.RemoteHostCallUsingRunspaceHost : RemotingDataType.RemoteHostCallUsingPowerShellHost;
     this._serverDispatchTable    = new ServerDispatchTable();
 }
Exemplo n.º 4
0
 internal ServerRemoteHost(Guid clientRunspacePoolId, Guid clientPowerShellId, System.Management.Automation.Remoting.HostInfo hostInfo, AbstractServerTransportManager transportManager)
 {
     this._clientRunspacePoolId    = clientRunspacePoolId;
     this._clientPowerShellId      = clientPowerShellId;
     this._hostInfo                = hostInfo;
     this._transportManager        = transportManager;
     this._serverMethodExecutor    = new System.Management.Automation.Remoting.ServerMethodExecutor(clientRunspacePoolId, clientPowerShellId, this._transportManager);
     this._remoteHostUserInterface = hostInfo.IsHostUINull ? null : new ServerRemoteHostUserInterface(this);
 }
Exemplo n.º 5
0
 internal ServerRemoteHost(Guid clientRunspacePoolId, Guid clientPowerShellId, System.Management.Automation.Remoting.HostInfo hostInfo, AbstractServerTransportManager transportManager)
 {
     this._clientRunspacePoolId = clientRunspacePoolId;
     this._clientPowerShellId = clientPowerShellId;
     this._hostInfo = hostInfo;
     this._transportManager = transportManager;
     this._serverMethodExecutor = new System.Management.Automation.Remoting.ServerMethodExecutor(clientRunspacePoolId, clientPowerShellId, this._transportManager);
     this._remoteHostUserInterface = hostInfo.IsHostUINull ? null : new ServerRemoteHostUserInterface(this);
 }
 /// <summary>
 /// Constructor for ServerMethodExecutor.
 /// </summary>
 internal ServerMethodExecutor(
     Guid clientRunspacePoolId, Guid clientPowerShellId,
     AbstractServerTransportManager transportManager)
 {
     _clientRunspacePoolId = clientRunspacePoolId;
     _clientPowerShellId   = clientPowerShellId;
     Dbg.Assert(transportManager != null, "Expected transportManager != null");
     _transportManager       = transportManager;
     _remoteHostCallDataType =
         clientPowerShellId == Guid.Empty ? RemotingDataType.RemoteHostCallUsingRunspaceHost : RemotingDataType.RemoteHostCallUsingPowerShellHost;
     _serverDispatchTable = new ServerDispatchTable();
 }
 internal ServerPowerShellDataStructureHandler(Guid instanceId, Guid runspacePoolId, RemoteStreamOptions remoteStreamOptions, AbstractServerTransportManager transportManager, PowerShell localPowerShell)
 {
     this.clientPowerShellId = instanceId;
     this.clientRunspacePoolId = runspacePoolId;
     this.transportManager = transportManager;
     this.streamSerializationOptions = remoteStreamOptions;
     transportManager.Closing += new EventHandler(this.HandleTransportClosing);
     if (localPowerShell != null)
     {
         localPowerShell.RunspaceAssigned += new EventHandler<PSEventArgs<Runspace>>(this.LocalPowerShell_RunspaceAssigned);
     }
 }
 internal ServerPowerShellDataStructureHandler(Guid instanceId, Guid runspacePoolId, RemoteStreamOptions remoteStreamOptions, AbstractServerTransportManager transportManager, PowerShell localPowerShell)
 {
     this.clientPowerShellId         = instanceId;
     this.clientRunspacePoolId       = runspacePoolId;
     this.transportManager           = transportManager;
     this.streamSerializationOptions = remoteStreamOptions;
     transportManager.Closing       += new EventHandler(this.HandleTransportClosing);
     if (localPowerShell != null)
     {
         localPowerShell.RunspaceAssigned += new EventHandler <PSEventArgs <Runspace> >(this.LocalPowerShell_RunspaceAssigned);
     }
 }
 internal ServerPowerShellDataStructureHandler(
     ServerPowerShellDriver driver,
     AbstractServerTransportManager transportManager)
 {
     using (ServerPowerShellDataStructureHandler.tracer.TraceConstructor((object)this))
     {
         this.clientPowerShellId         = driver.InstanceId;
         this.clientRunspacePoolId       = driver.RunspacePoolId;
         this.transportManager           = transportManager;
         this.streamSerializationOptions = driver.RemoteStreamOptions;
         transportManager.Closing       += new EventHandler(this.HandleTransportClosing);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Default constructor for creating ServerPowerShellDataStructureHandler
        /// instance.
        /// </summary>
        /// <param name="instanceId">Powershell instance id.</param>
        /// <param name="runspacePoolId">Runspace pool id.</param>
        /// <param name="remoteStreamOptions">Remote stream options.</param>
        /// <param name="transportManager">Transport manager.</param>
        /// <param name="localPowerShell">Local powershell object.</param>
        internal ServerPowerShellDataStructureHandler(Guid instanceId, Guid runspacePoolId, RemoteStreamOptions remoteStreamOptions,
                                                      AbstractServerTransportManager transportManager, PowerShell localPowerShell)
        {
            _clientPowerShellId         = instanceId;
            _clientRunspacePoolId       = runspacePoolId;
            _transportManager           = transportManager;
            _streamSerializationOptions = remoteStreamOptions;
            transportManager.Closing   += HandleTransportClosing;

            if (localPowerShell != null)
            {
                localPowerShell.RunspaceAssigned += LocalPowerShell_RunspaceAssigned;
            }
        }
Exemplo n.º 11
0
 internal ServerPowerShellDataStructureHandler CreatePowerShellDataStructureHandler(
     ServerPowerShellDriver driver)
 {
     using (ServerRunspacePoolDataStructureHandler.tracer.TraceMethod())
     {
         AbstractServerTransportManager transportManager = (AbstractServerTransportManager)this.transportManager;
         if (driver.InstanceId != Guid.Empty)
         {
             transportManager = this.transportManager.GetCommandTransportManager(driver.InstanceId);
         }
         ServerPowerShellDataStructureHandler structureHandler = new ServerPowerShellDataStructureHandler(driver, transportManager);
         lock (this.associationSyncObject)
             this.associatedShells.Add(structureHandler.PowerShellId, structureHandler);
         structureHandler.RemoveAssociation += new EventHandler(this.HandleRemoveAssociation);
         return(structureHandler);
     }
 }
        internal ServerPowerShellDataStructureHandler CreatePowerShellDataStructureHandler(Guid instanceId, Guid runspacePoolId, RemoteStreamOptions remoteStreamOptions, PowerShell localPowerShell)
        {
            AbstractServerTransportManager transportManager = this.transportManager;

            if (instanceId != Guid.Empty)
            {
                transportManager = this.transportManager.GetCommandTransportManager(instanceId);
            }
            ServerPowerShellDataStructureHandler handler = new ServerPowerShellDataStructureHandler(instanceId, runspacePoolId, remoteStreamOptions, transportManager, localPowerShell);

            lock (this.associationSyncObject)
            {
                this.associatedShells.Add(handler.PowerShellId, handler);
            }
            handler.RemoveAssociation += new EventHandler(this.HandleRemoveAssociation);
            return(handler);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a powershell data structure handler from this runspace pool.
        /// </summary>
        /// <param name="instanceId">Powershell instance id.</param>
        /// <param name="runspacePoolId">Runspace pool id.</param>
        /// <param name="remoteStreamOptions">Remote stream options.</param>
        /// <param name="localPowerShell">Local PowerShell object.</param>
        /// <returns>ServerPowerShellDataStructureHandler.</returns>
        internal ServerPowerShellDataStructureHandler CreatePowerShellDataStructureHandler(
            Guid instanceId, Guid runspacePoolId, RemoteStreamOptions remoteStreamOptions, PowerShell localPowerShell)
        {
            // start with pool's transport manager.
            AbstractServerTransportManager cmdTransportManager = _transportManager;

            if (instanceId != Guid.Empty)
            {
                cmdTransportManager = _transportManager.GetCommandTransportManager(instanceId);
                Dbg.Assert(cmdTransportManager.TypeTable != null, "This should be already set in managed C++ code");
            }

            ServerPowerShellDataStructureHandler dsHandler =
                new ServerPowerShellDataStructureHandler(instanceId, runspacePoolId, remoteStreamOptions, cmdTransportManager, localPowerShell);

            lock (_associationSyncObject)
            {
                _associatedShells.Add(dsHandler.PowerShellId, dsHandler);
            }

            dsHandler.RemoveAssociation += new EventHandler(HandleRemoveAssociation);

            return(dsHandler);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Used by Command Session to apply quotas on the command transport manager.
 /// This method is here because ServerRemoteSession knows about InitialSessionState.
 /// </summary>
 /// <param name="cmdTransportManager">
 /// Command TransportManager to apply the quota on.
 /// </param>
 internal void ApplyQuotaOnCommandTransportManager(AbstractServerTransportManager cmdTransportManager)
 {
     Dbg.Assert(null != cmdTransportManager, "cmdTransportManager cannot be null");
     cmdTransportManager.ReceivedDataCollection.MaximumReceivedDataSize = _maxRecvdDataSizeCommand;
     cmdTransportManager.ReceivedDataCollection.MaximumReceivedObjectSize = _maxRecvdObjectSize;
 }
Exemplo n.º 15
0
 internal void ApplyQuotaOnCommandTransportManager(
     AbstractServerTransportManager cmdTransportManager)
 {
     cmdTransportManager.ReceivedDataCollection.MaximumReceivedDataSize   = this.maxRecvdDataSizeCommand;
     cmdTransportManager.ReceivedDataCollection.MaximumReceivedObjectSize = this.maxRecvdObjectSize;
 }
Exemplo n.º 16
0
 internal void ApplyQuotaOnCommandTransportManager(AbstractServerTransportManager cmdTransportManager)
 {
     cmdTransportManager.ReceivedDataCollection.MaximumReceivedDataSize = this.maxRecvdDataSizeCommand;
     cmdTransportManager.ReceivedDataCollection.MaximumReceivedObjectSize = this.maxRecvdObjectSize;
 }