internal static RemoteDataObject GeneratePowerShellStateInfo( PSInvocationStateInfo stateInfo, Guid clientPowerShellId, Guid clientRunspacePoolId) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); PSNoteProperty psNoteProperty = new PSNoteProperty("PipelineState", (object)(int)stateInfo.State); emptyPsObject.Properties.Add((PSPropertyInfo)psNoteProperty); if (stateInfo.Reason != null) { string errorId = "RemotePSInvocationStateInfoReason"; PSNoteProperty exceptionProperty = RemotingEncoder.GetExceptionProperty(stateInfo.Reason, errorId, ErrorCategory.NotSpecified); emptyPsObject.Properties.Add((PSPropertyInfo)exceptionProperty); } return(RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.PowerShellStateInfo, clientRunspacePoolId, clientPowerShellId, (object)emptyPsObject)); } }
internal static RemoteDataObject GenerateCreateRunspacePool( Guid clientRunspacePoolId, int minRunspaces, int maxRunspaces, RemoteRunspacePoolInternal runspacePool, PSHost host, PSPrimitiveDictionary applicationArguments) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("MinRunspaces", (object)minRunspaces)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("MaxRunspaces", (object)maxRunspaces)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSThreadOptions", (object)runspacePool.ThreadOptions)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ApartmentState", (object)runspacePool.ApartmentState)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ApplicationArguments", (object)applicationArguments)); emptyPsObject.Properties.Add((PSPropertyInfo)RemotingEncoder.CreateHostInfoProperty(new HostInfo(host))); return(RemoteDataObject.CreateFrom(RemotingDestination.Server, RemotingDataType.CreateRunspacePool, clientRunspacePoolId, Guid.Empty, (object)emptyPsObject)); } }
internal static RemoteDataObject GenerateCreatePowerShell(ClientRemotePowerShell shell) { HostInfo info; PowerShell powerShell = shell.PowerShell; PSInvocationSettings settings = shell.Settings; PSObject data = CreateEmptyPSObject(); Guid empty = Guid.Empty; ApartmentState unknown = ApartmentState.Unknown; RunspacePool runspaceConnection = powerShell.GetRunspaceConnection() as RunspacePool; empty = runspaceConnection.InstanceId; unknown = runspaceConnection.ApartmentState; data.Properties.Add(new PSNoteProperty("PowerShell", powerShell.ToPSObjectForRemoting())); data.Properties.Add(new PSNoteProperty("NoInput", shell.NoInput)); if (settings == null) { info = new HostInfo(null) { UseRunspaceHost = true }; data.Properties.Add(new PSNoteProperty("ApartmentState", unknown)); data.Properties.Add(new PSNoteProperty("RemoteStreamOptions", RemoteStreamOptions.AddInvocationInfo)); data.Properties.Add(new PSNoteProperty("AddToHistory", false)); } else { info = new HostInfo(settings.Host); if (settings.Host == null) { info.UseRunspaceHost = true; } data.Properties.Add(new PSNoteProperty("ApartmentState", settings.ApartmentState)); data.Properties.Add(new PSNoteProperty("RemoteStreamOptions", settings.RemoteStreamOptions)); data.Properties.Add(new PSNoteProperty("AddToHistory", settings.AddToHistory)); } PSNoteProperty member = CreateHostInfoProperty(info); data.Properties.Add(member); data.Properties.Add(new PSNoteProperty("IsNested", shell.PowerShell.IsNested)); return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Server, RemotingDataType.CreatePowerShell, empty, shell.InstanceId, data)); }
internal static RemoteDataObject GenerateConnectRunspacePool(Guid clientRunspacePoolId, int minRunspaces, int maxRunspaces) { PSObject data = CreateEmptyPSObject(); int num = 0; if (minRunspaces != -1) { data.Properties.Add(new PSNoteProperty("MinRunspaces", minRunspaces)); num++; } if (maxRunspaces != -1) { data.Properties.Add(new PSNoteProperty("MaxRunspaces", maxRunspaces)); num++; } if (num > 0) { return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Server, RemotingDataType.ConnectRunspacePool, clientRunspacePoolId, Guid.Empty, data)); } return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Server, RemotingDataType.ConnectRunspacePool, clientRunspacePoolId, Guid.Empty, string.Empty)); }
internal static RemoteDataObject GenerateCreatePowerShell( ClientRemotePowerShell shell) { PowerShell powerShell = shell.PowerShell; PSInvocationSettings settings = shell.Settings; PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); Guid empty = Guid.Empty; RunspacePool runspaceConnection = powerShell.GetRunspaceConnection() as RunspacePool; Guid instanceId = runspaceConnection.InstanceId; ApartmentState apartmentState = runspaceConnection.ApartmentState; emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PowerShell", (object)powerShell.ToPSObjectForRemoting())); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("NoInput", (object)shell.NoInput)); HostInfo hostInfo; if (settings == null) { hostInfo = new HostInfo((PSHost)null); hostInfo.UseRunspaceHost = true; emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ApartmentState", (object)apartmentState)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("RemoteStreamOptions", (object)RemoteStreamOptions.AddInvocationInfo)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("AddToHistory", (object)false)); } else { hostInfo = new HostInfo(settings.Host); if (settings.Host == null) { hostInfo.UseRunspaceHost = true; } emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ApartmentState", (object)settings.ApartmentState)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("RemoteStreamOptions", (object)settings.RemoteStreamOptions)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("AddToHistory", (object)settings.AddToHistory)); } PSNoteProperty hostInfoProperty = RemotingEncoder.CreateHostInfoProperty(hostInfo); emptyPsObject.Properties.Add((PSPropertyInfo)hostInfoProperty); return(RemoteDataObject.CreateFrom(RemotingDestination.Server, RemotingDataType.CreatePowerShell, instanceId, shell.InstanceId, (object)emptyPsObject)); }
internal void SendHostResponseToServer(RemoteHostResponse hostResponse) { using (ClientPowerShellDataStructureHandler.tracer.TraceMethod()) this.transportManager.DataToBeSentCollection.Add <PSObject>(RemoteDataObject <PSObject> .CreateFrom(RemotingDestination.Server, RemotingDataType.RemotePowerShellHostResponseData, this.clientRunspacePoolId, this.clientPowerShellId, hostResponse.Encode()), DataPriorityType.PromptResponse); }
internal void SendHostResponseToServer(RemoteHostResponse hostResponse) { RemoteDataObject <PSObject> data = RemoteDataObject <PSObject> .CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Server, RemotingDataType.RemotePowerShellHostResponseData, this.clientRunspacePoolId, this.clientPowerShellId, hostResponse.Encode()); this.transportManager.DataToBeSentCollection.Add <PSObject>(data, DataPriorityType.PromptResponse); }
internal static RemoteDataObject GeneratePublicKeyRequest(Guid runspacePoolId) => RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.PublicKeyRequest, runspacePoolId, Guid.Empty, (object)string.Empty);
internal void SendDataAsync(PSObject data, DataPriorityType priority) { using (ClientRunspacePoolDataStructureHandler.tracer.TraceMethod()) this.transportManager.DataToBeSentCollection.Add <PSObject>(RemoteDataObject <PSObject> .CreateFrom(RemotingDestination.Server, RemotingDataType.InvalidDataType, this.clientRunspacePoolId, Guid.Empty, data)); }
internal void SendDataAsync(PSObject data, DataPriorityType priority) { RemoteDataObject <PSObject> obj2 = RemoteDataObject <PSObject> .CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Server, RemotingDataType.InvalidDataType, this.clientRunspacePoolId, Guid.Empty, data); this.transportManager.DataToBeSentCollection.Add <PSObject>(obj2); }
internal static RemoteDataObject GenerateServerSessionCapability(RemoteSessionCapability capability, Guid runspacePoolId) { PSObject data = GenerateSessionCapability(capability); return(RemoteDataObject.CreateFrom(capability.RemotingDestination, RemotingDataType.SessionCapability, runspacePoolId, Guid.Empty, data)); }
internal static RemoteDataObject GeneratePublicKeyRequest(Guid runspacePoolId) { return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Client, RemotingDataType.PublicKeyRequest, runspacePoolId, Guid.Empty, string.Empty)); }
internal static RemoteDataObject GeneratePowerShellOutput(PSObject data, Guid clientPowerShellId, Guid clientRunspacePoolId) { return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Client, RemotingDataType.PowerShellOutput, clientRunspacePoolId, clientPowerShellId, data)); }
internal static RemoteDataObject GeneratePowerShellInputEnd(Guid clientRemoteRunspacePoolId, Guid clientPowerShellId) { return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Server, RemotingDataType.PowerShellInputEnd, clientRemoteRunspacePoolId, clientPowerShellId, null)); }
internal static RemoteDataObject GeneratePowerShellInformational(object data, Guid clientRunspacePoolId, Guid clientPowerShellId, RemotingDataType dataType) { return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Client, dataType, clientRunspacePoolId, clientPowerShellId, PSObject.AsPSObject(data))); }
internal static RemoteDataObject GeneratePowerShellError(object errorRecord, Guid clientRunspacePoolId, Guid clientPowerShellId) { return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Client, RemotingDataType.PowerShellErrorRecord, clientRunspacePoolId, clientPowerShellId, PSObject.AsPSObject(errorRecord))); }