internal void ProcessReceivedData(RemoteDataObject <PSObject> receivedData)
        {
            if (receivedData.RunspacePoolId != this.clientRunspacePoolId)
            {
                throw new PSRemotingDataStructureException(RemotingErrorIdStrings.RunspaceIdsDoNotMatch, new object[] { receivedData.RunspacePoolId, this.clientRunspacePoolId });
            }
            switch (receivedData.DataType)
            {
            case RemotingDataType.RunspacePoolOperationResponse:
                this.SetMaxMinRunspacesResponseRecieved.SafeInvoke <RemoteDataEventArgs <PSObject> >(this, new RemoteDataEventArgs <PSObject>(receivedData.Data));
                return;

            case RemotingDataType.RunspacePoolStateInfo:
            {
                RunspacePoolStateInfo runspacePoolStateInfo = RemotingDecoder.GetRunspacePoolStateInfo(receivedData.Data);
                this.StateInfoReceived.SafeInvoke <RemoteDataEventArgs <RunspacePoolStateInfo> >(this, new RemoteDataEventArgs <RunspacePoolStateInfo>(runspacePoolStateInfo));
                this.NotifyAssociatedPowerShells(runspacePoolStateInfo);
                return;
            }

            case RemotingDataType.CreatePowerShell:
            case RemotingDataType.AvailableRunspaces:
            case RemotingDataType.GetCommandMetadata:
                break;

            case RemotingDataType.PSEventArgs:
            {
                PSEventArgs pSEventArgs = RemotingDecoder.GetPSEventArgs(receivedData.Data);
                this.PSEventArgsReceived.SafeInvoke <RemoteDataEventArgs <PSEventArgs> >(this, new RemoteDataEventArgs <PSEventArgs>(pSEventArgs));
                break;
            }

            case RemotingDataType.ApplicationPrivateData:
            {
                PSPrimitiveDictionary applicationPrivateData = RemotingDecoder.GetApplicationPrivateData(receivedData.Data);
                this.ApplicationPrivateDataReceived.SafeInvoke <RemoteDataEventArgs <PSPrimitiveDictionary> >(this, new RemoteDataEventArgs <PSPrimitiveDictionary>(applicationPrivateData));
                return;
            }

            case RemotingDataType.RunspacePoolInitData:
            {
                RunspacePoolInitInfo runspacePoolInitInfo = RemotingDecoder.GetRunspacePoolInitInfo(receivedData.Data);
                this.RSPoolInitInfoReceived.SafeInvoke <RemoteDataEventArgs <RunspacePoolInitInfo> >(this, new RemoteDataEventArgs <RunspacePoolInitInfo>(runspacePoolInitInfo));
                return;
            }

            case RemotingDataType.RemoteHostCallUsingRunspaceHost:
            {
                RemoteHostCall data = RemoteHostCall.Decode(receivedData.Data);
                this.RemoteHostCallReceived.SafeInvoke <RemoteDataEventArgs <RemoteHostCall> >(this, new RemoteDataEventArgs <RemoteHostCall>(data));
                return;
            }

            default:
                return;
            }
        }
        internal void ProcessReceivedData(RemoteDataObject <PSObject> receivedData)
        {
            using (ClientPowerShellDataStructureHandler.tracer.TraceMethod())
            {
                if (receivedData.PowerShellId != this.clientPowerShellId)
                {
                    throw new PSRemotingDataStructureException(PSRemotingErrorId.PipelineIdsDoNotMatch, new object[2]
                    {
                        (object)receivedData.PowerShellId,
                        (object)this.clientPowerShellId
                    });
                }
                switch (receivedData.DataType)
                {
                case RemotingDataType.PowerShellOutput:
                    this.OutputReceived((object)this, new RemoteDataEventArgs <object>(RemotingDecoder.GetPowerShellOutput((object)receivedData.Data)));
                    break;

                case RemotingDataType.PowerShellErrorRecord:
                    this.ErrorReceived((object)this, new RemoteDataEventArgs <ErrorRecord>((object)RemotingDecoder.GetPowerShellError((object)receivedData.Data)));
                    break;

                case RemotingDataType.PowerShellStateInfo:
                    this.InvocationStateInfoReceived((object)this, new RemoteDataEventArgs <PSInvocationStateInfo>((object)RemotingDecoder.GetPowerShellStateInfo((object)receivedData.Data)));
                    break;

                case RemotingDataType.PowerShellDebug:
                    this.InformationalMessageReceived((object)this, new RemoteDataEventArgs <InformationalMessage>((object)new InformationalMessage((object)RemotingDecoder.GetPowerShellDebug((object)receivedData.Data), RemotingDataType.PowerShellDebug)));
                    break;

                case RemotingDataType.PowerShellVerbose:
                    this.InformationalMessageReceived((object)this, new RemoteDataEventArgs <InformationalMessage>((object)new InformationalMessage((object)RemotingDecoder.GetPowerShellVerbose((object)receivedData.Data), RemotingDataType.PowerShellVerbose)));
                    break;

                case RemotingDataType.PowerShellWarning:
                    this.InformationalMessageReceived((object)this, new RemoteDataEventArgs <InformationalMessage>((object)new InformationalMessage((object)RemotingDecoder.GetPowerShellWarning((object)receivedData.Data), RemotingDataType.PowerShellWarning)));
                    break;

                case RemotingDataType.PowerShellProgress:
                    this.InformationalMessageReceived((object)this, new RemoteDataEventArgs <InformationalMessage>((object)new InformationalMessage((object)RemotingDecoder.GetPowerShellProgress((object)receivedData.Data), RemotingDataType.PowerShellProgress)));
                    break;

                case RemotingDataType.RemoteHostCallUsingPowerShellHost:
                    this.HostCallReceived((object)this, new RemoteDataEventArgs <RemoteHostCall>((object)RemoteHostCall.Decode(receivedData.Data)));
                    break;
                }
            }
        }
        internal void ProcessReceivedData(RemoteDataObject <PSObject> receivedData)
        {
            if (receivedData.PowerShellId != this.clientPowerShellId)
            {
                throw new PSRemotingDataStructureException(RemotingErrorIdStrings.PipelineIdsDoNotMatch, new object[] { receivedData.PowerShellId, this.clientPowerShellId });
            }
            switch (receivedData.DataType)
            {
            case RemotingDataType.PowerShellOutput:
            {
                object powerShellOutput = RemotingDecoder.GetPowerShellOutput(receivedData.Data);
                this.OutputReceived.SafeInvoke <RemoteDataEventArgs <object> >(this, new RemoteDataEventArgs <object>(powerShellOutput));
                return;
            }

            case RemotingDataType.PowerShellErrorRecord:
            {
                ErrorRecord powerShellError = RemotingDecoder.GetPowerShellError(receivedData.Data);
                this.ErrorReceived.SafeInvoke <RemoteDataEventArgs <ErrorRecord> >(this, new RemoteDataEventArgs <ErrorRecord>(powerShellError));
                return;
            }

            case RemotingDataType.PowerShellStateInfo:
            {
                PSInvocationStateInfo powerShellStateInfo = RemotingDecoder.GetPowerShellStateInfo(receivedData.Data);
                this.InvocationStateInfoReceived.SafeInvoke <RemoteDataEventArgs <PSInvocationStateInfo> >(this, new RemoteDataEventArgs <PSInvocationStateInfo>(powerShellStateInfo));
                return;
            }

            case RemotingDataType.PowerShellDebug:
            {
                DebugRecord powerShellDebug = RemotingDecoder.GetPowerShellDebug(receivedData.Data);
                this.InformationalMessageReceived.SafeInvoke <RemoteDataEventArgs <InformationalMessage> >(this, new RemoteDataEventArgs <InformationalMessage>(new InformationalMessage(powerShellDebug, RemotingDataType.PowerShellDebug)));
                return;
            }

            case RemotingDataType.PowerShellVerbose:
            {
                VerboseRecord powerShellVerbose = RemotingDecoder.GetPowerShellVerbose(receivedData.Data);
                this.InformationalMessageReceived.SafeInvoke <RemoteDataEventArgs <InformationalMessage> >(this, new RemoteDataEventArgs <InformationalMessage>(new InformationalMessage(powerShellVerbose, RemotingDataType.PowerShellVerbose)));
                return;
            }

            case RemotingDataType.PowerShellWarning:
            {
                WarningRecord powerShellWarning = RemotingDecoder.GetPowerShellWarning(receivedData.Data);
                this.InformationalMessageReceived.SafeInvoke <RemoteDataEventArgs <InformationalMessage> >(this, new RemoteDataEventArgs <InformationalMessage>(new InformationalMessage(powerShellWarning, RemotingDataType.PowerShellWarning)));
                return;
            }

            case ((RemotingDataType)0x4100a):
            case ((RemotingDataType)0x4100b):
            case ((RemotingDataType)0x4100c):
            case ((RemotingDataType)0x4100d):
            case ((RemotingDataType)0x4100e):
            case ((RemotingDataType)0x4100f):
                break;

            case RemotingDataType.PowerShellProgress:
            {
                ProgressRecord powerShellProgress = RemotingDecoder.GetPowerShellProgress(receivedData.Data);
                this.InformationalMessageReceived.SafeInvoke <RemoteDataEventArgs <InformationalMessage> >(this, new RemoteDataEventArgs <InformationalMessage>(new InformationalMessage(powerShellProgress, RemotingDataType.PowerShellProgress)));
                return;
            }

            case RemotingDataType.RemoteHostCallUsingPowerShellHost:
            {
                RemoteHostCall data = RemoteHostCall.Decode(receivedData.Data);
                this.HostCallReceived.SafeInvoke <RemoteDataEventArgs <RemoteHostCall> >(this, new RemoteDataEventArgs <RemoteHostCall>(data));
                break;
            }

            default:
                return;
            }
        }
Ejemplo n.º 4
0
        internal void ProcessReceivedData(RemoteDataObject <PSObject> receivedData)
        {
            using (ClientRunspacePoolDataStructureHandler.tracer.TraceMethod())
            {
                if (receivedData.RunspacePoolId != this.clientRunspacePoolId)
                {
                    throw new PSRemotingDataStructureException(PSRemotingErrorId.RunspaceIdsDoNotMatch, new object[2]
                    {
                        (object)receivedData.RunspacePoolId,
                        (object)this.clientRunspacePoolId
                    });
                }
                switch (receivedData.DataType)
                {
                case RemotingDataType.RunspacePoolOperationResponse:
                    this.SetMaxMinRunspacesResponseRecieved((object)this, new RemoteDataEventArgs <PSObject>((object)receivedData.Data));
                    break;

                case RemotingDataType.RunspacePoolStateInfo:
                    RunspacePoolStateInfo runspacePoolStateInfo = RemotingDecoder.GetRunspacePoolStateInfo(receivedData.Data);
                    this.StateInfoReceived((object)this, new RemoteDataEventArgs <RunspacePoolStateInfo>((object)runspacePoolStateInfo));
                    this.NotifyAssociatedPowerShells(runspacePoolStateInfo);
                    break;

                case RemotingDataType.PSEventArgs:
                    this.PSEventArgsReceived((object)this, new RemoteDataEventArgs <PSEventArgs>((object)RemotingDecoder.GetPSEventArgs(receivedData.Data)));
                    break;

                case RemotingDataType.ApplicationPrivateData:
                    this.ApplicationPrivateDataReceived((object)this, new RemoteDataEventArgs <PSPrimitiveDictionary>((object)RemotingDecoder.GetApplicationPrivateData(receivedData.Data)));
                    break;

                case RemotingDataType.RemoteHostCallUsingRunspaceHost:
                    this.RemoteHostCallReceived((object)this, new RemoteDataEventArgs <RemoteHostCall>((object)RemoteHostCall.Decode(receivedData.Data)));
                    break;
                }
            }
        }