public PSObject ToPSObjectForRemoting() { var obj = RemotingEncoder.CreateEmptyPSObject(); obj.AddOrSetProperty(new PSNoteProperty("Version", this.Version)); obj.AddOrSetProperty(new PSNoteProperty("ConnectionInfoType", this.ConnectionInfo.GetType().Name)); obj.AddOrSetProperty(new PSNoteProperty("ConnectionInfo", this.ConnectionInfo.ToPSObjectForRemoting())); obj.AddOrSetProperty(new PSNoteProperty("OriginalConnectionInfoType", this.OriginalConnectionInfo.GetType().Name)); obj.AddOrSetProperty(new PSNoteProperty("OriginalConnectionInfo", this.OriginalConnectionInfo.ToPSObjectForRemoting())); obj.AddOrSetProperty(new PSNoteProperty("ApplicationArguments", this._applicationArguments)); obj.AddOrSetProperty(new PSNoteProperty("RunspaceStateInfo", this.RunspaceStateInfo.State)); obj.AddOrSetProperty(new PSNoteProperty("ApartmentState", this.ApartmentState)); obj.AddOrSetProperty(new PSNoteProperty("ByPassRunspaceStateCheck", this.ByPassRunspaceStateCheck)); obj.AddOrSetProperty(new PSNoteProperty("SessionStateProxyCallInProgress", this._bSessionStateProxyCallInProgress)); obj.AddOrSetProperty(new PSNoteProperty("CanConnect", this.CanConnect)); obj.AddOrSetProperty(new PSNoteProperty("CanDisconnect", this.CanDisconnect)); obj.AddOrSetProperty(new PSNoteProperty("EngineActivityId", this.EngineActivityId)); obj.AddOrSetProperty(new PSNoteProperty("HasAvailabilityChangedSubscribers", this.HasAvailabilityChangedSubscribers)); obj.AddOrSetProperty(new PSNoteProperty("Id", this.Id)); obj.AddOrSetProperty(new PSNoteProperty("InNestedPrompt", this.InNestedPrompt)); obj.AddOrSetProperty(new PSNoteProperty("InstanceId", this.InstanceId)); obj.AddOrSetProperty(new PSNoteProperty("Name", this.Name)); obj.AddOrSetProperty(new PSNoteProperty("RemoteCommand", this.RemoteCommand)); obj.AddOrSetProperty(new PSNoteProperty("RunspaceAvailability", this.RunspaceAvailability)); obj.AddOrSetProperty(new PSNoteProperty("ShouldCloseOnPop", this.ShouldCloseOnPop)); obj.AddOrSetProperty(new PSNoteProperty("ThreadOptions", this.ThreadOptions)); return(obj); }
internal static RemoteDataObject GenerateEncryptedSessionKeyResponse( Guid runspacePoolId, string encryptedSessionKey) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("EncryptedSessionKey", (object)encryptedSessionKey)); return(RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.EncryptedSessionKey, runspacePoolId, Guid.Empty, (object)emptyPsObject)); }
internal static RemoteDataObject GenerateGetAvailableRunspaces( Guid clientRunspacePoolId, long callId) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ci", (object)callId)); return(RemoteDataObject.CreateFrom(RemotingDestination.Server, RemotingDataType.AvailableRunspaces, clientRunspacePoolId, Guid.Empty, (object)emptyPsObject)); }
public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { if (info != null) { PSObject dest = RemotingEncoder.CreateEmptyPSObject(); this.ToPSObjectForRemoting(dest, true); dest.GetObjectData(info, context); } }
private static PSObject GenerateSessionCapability(RemoteSessionCapability capability) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("protocolversion", (object)capability.ProtocolVersion)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSVersion", (object)capability.PSVersion)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("SerializationVersion", (object)capability.SerializationVersion)); return(emptyPsObject); }
internal static RemoteDataObject GenerateMyPublicKey( Guid runspacePoolId, string publicKey, RemotingDestination destination) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PublicKey", (object)publicKey)); return(RemoteDataObject.CreateFrom(destination, RemotingDataType.PublicKey, runspacePoolId, Guid.Empty, (object)emptyPsObject)); }
internal static RemoteDataObject GenerateApplicationPrivateData( Guid clientRunspacePoolId, PSPrimitiveDictionary applicationPrivateData) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ApplicationPrivateData", (object)applicationPrivateData)); return(RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.ApplicationPrivateData, clientRunspacePoolId, Guid.Empty, (object)emptyPsObject)); } }
internal static RemoteDataObject GenerateSetMinRunspaces( Guid clientRunspacePoolId, int minRunspaces, long callId) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("MinRunspaces", (object)minRunspaces)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ci", (object)callId)); return(RemoteDataObject.CreateFrom(RemotingDestination.Server, RemotingDataType.SetMinRunspaces, clientRunspacePoolId, Guid.Empty, (object)emptyPsObject)); } }
internal static RemoteDataObject GenerateRunspacePoolOperationResponse( Guid clientRunspacePoolId, object response, long callId) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("SetMinMaxRunspacesResponse", response)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ci", (object)callId)); return(RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.RunspacePoolOperationResponse, clientRunspacePoolId, Guid.Empty, (object)emptyPsObject)); } }
internal PSObject ToPSObjectForRemoting() { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("Activity", (object)this.Activity)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ActivityId", (object)this.ActivityId)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("StatusDescription", (object)this.StatusDescription)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("CurrentOperation", (object)this.CurrentOperation)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ParentActivityId", (object)this.ParentActivityId)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PercentComplete", (object)this.PercentComplete)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("Type", (object)this.RecordType)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("SecondsRemaining", (object)this.SecondsRemaining)); return(emptyPsObject); }
/// <summary> /// Returns this object as a PSObject property bag /// that can be used in a remoting protocol data object. /// </summary> /// <returns>This object as a PSObject property bag.</returns> internal PSObject ToPSObjectForRemoting() { PSObject progressAsPSObject = RemotingEncoder.CreateEmptyPSObject(); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_Activity, this.Activity)); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_ActivityId, this.ActivityId)); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_StatusDescription, this.StatusDescription)); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_CurrentOperation, this.CurrentOperation)); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_ParentActivityId, this.ParentActivityId)); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_PercentComplete, this.PercentComplete)); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_Type, this.RecordType)); progressAsPSObject.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.ProgressRecord_SecondsRemaining, this.SecondsRemaining)); return(progressAsPSObject); }
/// <summary> /// Returns this object as a PSObject property bag /// that can be used in a remoting protocol data object. /// </summary> /// <returns>This object as a PSObject property bag</returns> internal PSObject ToPSObjectForRemoting() { PSObject informationAsPSObject = RemotingEncoder.CreateEmptyPSObject(); informationAsPSObject.Properties.Add(new PSNoteProperty("MessageData", this.MessageData)); informationAsPSObject.Properties.Add(new PSNoteProperty("Source", this.Source)); informationAsPSObject.Properties.Add(new PSNoteProperty("TimeGenerated", this.TimeGenerated)); informationAsPSObject.Properties.Add(new PSNoteProperty("Tags", this.Tags)); informationAsPSObject.Properties.Add(new PSNoteProperty("User", this.User)); informationAsPSObject.Properties.Add(new PSNoteProperty("Computer", this.Computer)); informationAsPSObject.Properties.Add(new PSNoteProperty("ProcessId", this.ProcessId)); informationAsPSObject.Properties.Add(new PSNoteProperty("NativeThreadId", this.NativeThreadId)); informationAsPSObject.Properties.Add(new PSNoteProperty("ManagedThreadId", this.ManagedThreadId)); return(informationAsPSObject); }
internal static RemoteDataObject GenerateGetCommandMetadata( ClientRemotePowerShell shell) { Command command1 = (Command)null; foreach (Command command2 in (Collection <Command>)shell.PowerShell.Commands.Commands) { if (command2.CommandText.Equals("Get-Command", StringComparison.OrdinalIgnoreCase)) { command1 = command2; break; } } string[] strArray1 = (string[])null; CommandTypes commandTypes = CommandTypes.Alias | CommandTypes.Function | CommandTypes.Filter | CommandTypes.Cmdlet; string[] strArray2 = (string[])null; object[] objArray = (object[])null; foreach (CommandParameter parameter in (Collection <CommandParameter>)command1.Parameters) { if (parameter.Name.Equals("Name", StringComparison.OrdinalIgnoreCase)) { strArray1 = (string[])LanguagePrimitives.ConvertTo(parameter.Value, typeof(string[]), (IFormatProvider)CultureInfo.InvariantCulture); } else if (parameter.Name.Equals("CommandType", StringComparison.OrdinalIgnoreCase)) { commandTypes = (CommandTypes)LanguagePrimitives.ConvertTo(parameter.Value, typeof(CommandTypes), (IFormatProvider)CultureInfo.InvariantCulture); } else if (parameter.Name.Equals("Module", StringComparison.OrdinalIgnoreCase)) { strArray2 = (string[])LanguagePrimitives.ConvertTo(parameter.Value, typeof(string[]), (IFormatProvider)CultureInfo.InvariantCulture); } else if (parameter.Name.Equals("ArgumentList", StringComparison.OrdinalIgnoreCase)) { objArray = (object[])LanguagePrimitives.ConvertTo(parameter.Value, typeof(object[]), (IFormatProvider)CultureInfo.InvariantCulture); } } Guid instanceId = (shell.PowerShell.GetRunspaceConnection() as RunspacePool).InstanceId; PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("Name", (object)strArray1)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("CommandType", (object)commandTypes)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("Namespace", (object)strArray2)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("ArgumentList", (object)objArray)); return(RemoteDataObject.CreateFrom(RemotingDestination.Server, RemotingDataType.GetCommandMetadata, instanceId, shell.InstanceId, (object)emptyPsObject)); }
internal static RemoteDataObject GenerateRunspacePoolStateInfo( Guid clientRunspacePoolId, RunspacePoolStateInfo stateInfo) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); PSNoteProperty psNoteProperty = new PSNoteProperty("RunspaceState", (object)(int)stateInfo.State); emptyPsObject.Properties.Add((PSPropertyInfo)psNoteProperty); if (stateInfo.Reason != null) { string errorId = "RemoteRunspaceStateInfoReason"; PSNoteProperty exceptionProperty = RemotingEncoder.GetExceptionProperty(stateInfo.Reason, errorId, ErrorCategory.NotSpecified); emptyPsObject.Properties.Add((PSPropertyInfo)exceptionProperty); } return(RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.RunspacePoolStateInfo, clientRunspacePoolId, Guid.Empty, (object)emptyPsObject)); } }
internal static RemoteDataObject GeneratePSEventArgs( Guid clientRunspacePoolId, PSEventArgs e) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.EventIdentifier", (object)e.EventIdentifier)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.SourceIdentifier", (object)e.SourceIdentifier)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.TimeGenerated", (object)e.TimeGenerated)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.Sender", e.Sender)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.SourceArgs", (object)e.SourceArgs)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.MessageData", (object)e.MessageData)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.ComputerName", (object)e.ComputerName)); emptyPsObject.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSEventArgs.RunspaceId", (object)e.RunspaceId)); return(RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.PSEventArgs, clientRunspacePoolId, Guid.Empty, (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) { 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)); }