mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Seal classes in RemotingProtocol2 (#21164)
This commit is contained in:
@@ -19,7 +19,7 @@ namespace System.Management.Automation.Internal
|
||||
/// Handles all PowerShell data structure handler communication with the
|
||||
/// server side RunspacePool.
|
||||
/// </summary>
|
||||
internal class ClientRunspacePoolDataStructureHandler : IDisposable
|
||||
internal sealed class ClientRunspacePoolDataStructureHandler : IDisposable
|
||||
{
|
||||
private bool _reconnecting = false;
|
||||
|
||||
@@ -823,7 +823,7 @@ namespace System.Management.Automation.Internal
|
||||
{
|
||||
remoteSession?.DisconnectAsync();
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
// remoteSession may have already been disposed resulting in unexpected exceptions.
|
||||
}
|
||||
@@ -981,7 +981,7 @@ namespace System.Management.Automation.Internal
|
||||
/// Base class for ClientPowerShellDataStructureHandler to handle all
|
||||
/// references.
|
||||
/// </summary>
|
||||
internal class ClientPowerShellDataStructureHandler
|
||||
internal sealed class ClientPowerShellDataStructureHandler
|
||||
{
|
||||
#region Data Structure Handler events
|
||||
|
||||
@@ -1152,8 +1152,8 @@ namespace System.Management.Automation.Internal
|
||||
RemoteDataObject<PSObject> dataToBeSent =
|
||||
RemoteDataObject<PSObject>.CreateFrom(RemotingDestination.Server,
|
||||
RemotingDataType.RemotePowerShellHostResponseData,
|
||||
clientRunspacePoolId,
|
||||
clientPowerShellId,
|
||||
_clientRunspacePoolId,
|
||||
_clientPowerShellId,
|
||||
hostResponse.Encode());
|
||||
|
||||
TransportManager.DataToBeSentCollection.Add<PSObject>(dataToBeSent,
|
||||
@@ -1175,7 +1175,7 @@ namespace System.Management.Automation.Internal
|
||||
{
|
||||
// send input closed information to server
|
||||
SendDataAsync(RemotingEncoder.GeneratePowerShellInputEnd(
|
||||
clientRunspacePoolId, clientPowerShellId));
|
||||
_clientRunspacePoolId, _clientPowerShellId));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1204,10 +1204,10 @@ namespace System.Management.Automation.Internal
|
||||
internal void ProcessReceivedData(RemoteDataObject<PSObject> receivedData)
|
||||
{
|
||||
// verify if this data structure handler is the intended recipient
|
||||
if (receivedData.PowerShellId != clientPowerShellId)
|
||||
if (receivedData.PowerShellId != _clientPowerShellId)
|
||||
{
|
||||
throw new PSRemotingDataStructureException(RemotingErrorIdStrings.PipelineIdsDoNotMatch,
|
||||
receivedData.PowerShellId, clientPowerShellId);
|
||||
receivedData.PowerShellId, _clientPowerShellId);
|
||||
}
|
||||
|
||||
// decode the message and take appropriate action
|
||||
@@ -1470,13 +1470,6 @@ namespace System.Management.Automation.Internal
|
||||
|
||||
#endregion Data Structure Handler Methods
|
||||
|
||||
#region Protected Members
|
||||
|
||||
protected Guid clientRunspacePoolId;
|
||||
protected Guid clientPowerShellId;
|
||||
|
||||
#endregion Protected Members
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -1493,8 +1486,8 @@ namespace System.Management.Automation.Internal
|
||||
Guid clientRunspacePoolId, Guid clientPowerShellId)
|
||||
{
|
||||
TransportManager = transportManager;
|
||||
this.clientRunspacePoolId = clientRunspacePoolId;
|
||||
this.clientPowerShellId = clientPowerShellId;
|
||||
_clientRunspacePoolId = clientRunspacePoolId;
|
||||
_clientPowerShellId = clientPowerShellId;
|
||||
transportManager.SignalCompleted += OnSignalCompleted;
|
||||
}
|
||||
|
||||
@@ -1510,7 +1503,7 @@ namespace System.Management.Automation.Internal
|
||||
{
|
||||
get
|
||||
{
|
||||
return clientPowerShellId;
|
||||
return _clientPowerShellId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1563,7 +1556,7 @@ namespace System.Management.Automation.Internal
|
||||
foreach (object inputObject in inputObjects)
|
||||
{
|
||||
SendDataAsync(RemotingEncoder.GeneratePowerShellInput(inputObject,
|
||||
clientRunspacePoolId, clientPowerShellId));
|
||||
_clientRunspacePoolId, _clientPowerShellId));
|
||||
}
|
||||
|
||||
if (!inputstream.IsOpen)
|
||||
@@ -1574,7 +1567,7 @@ namespace System.Management.Automation.Internal
|
||||
foreach (object inputObject in inputObjects)
|
||||
{
|
||||
SendDataAsync(RemotingEncoder.GeneratePowerShellInput(inputObject,
|
||||
clientRunspacePoolId, clientPowerShellId));
|
||||
_clientRunspacePoolId, _clientPowerShellId));
|
||||
}
|
||||
|
||||
// we are sending input end to the server. Ignore the future
|
||||
@@ -1583,7 +1576,7 @@ namespace System.Management.Automation.Internal
|
||||
inputstream.DataReady -= HandleInputDataReady;
|
||||
// stream close: send end of input
|
||||
SendDataAsync(RemotingEncoder.GeneratePowerShellInputEnd(
|
||||
clientRunspacePoolId, clientPowerShellId));
|
||||
_clientRunspacePoolId, _clientPowerShellId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1605,6 +1598,9 @@ namespace System.Management.Automation.Internal
|
||||
|
||||
#region Private Members
|
||||
|
||||
private readonly Guid _clientRunspacePoolId;
|
||||
private readonly Guid _clientPowerShellId;
|
||||
|
||||
// object for synchronizing input to be sent
|
||||
// to server powershell
|
||||
private readonly object _inputSyncObject = new object();
|
||||
@@ -1623,7 +1619,7 @@ namespace System.Management.Automation.Internal
|
||||
#endregion Private Members
|
||||
}
|
||||
|
||||
internal class InformationalMessage
|
||||
internal sealed class InformationalMessage
|
||||
{
|
||||
internal object Message { get; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user