internal void SendApplicationPrivateDataToClient(PSPrimitiveDictionary applicationPrivateData, RemoteSessionCapability serverCapability)
        {
            PSPrimitiveDictionary dictionary  = PSPrimitiveDictionary.CloneAndAddPSVersionTable(applicationPrivateData);
            PSPrimitiveDictionary dictionary2 = (PSPrimitiveDictionary)dictionary["PSVersionTable"];

            dictionary2["PSRemotingProtocolVersion"] = serverCapability.ProtocolVersion;
            dictionary2["SerializationVersion"]      = serverCapability.SerializationVersion;
            dictionary2["PSVersion"] = serverCapability.PSVersion;
            RemoteDataObject data = RemotingEncoder.GenerateApplicationPrivateData(this.clientRunspacePoolId, dictionary);

            this.SendDataAsync(data);
        }
示例#2
0
 internal void SendApplicationPrivateDataToClient(
     PSPrimitiveDictionary applicationPrivateData,
     RemoteSessionCapability serverCapability)
 {
     using (ServerRunspacePoolDataStructureHandler.tracer.TraceMethod())
     {
         PSPrimitiveDictionary applicationPrivateData1 = PSPrimitiveDictionary.CloneAndAddPSVersionTable(applicationPrivateData);
         PSPrimitiveDictionary primitiveDictionary     = (PSPrimitiveDictionary)applicationPrivateData1["PSVersionTable"];
         primitiveDictionary["PSRemotingProtocolVersion"] = (object)serverCapability.ProtocolVersion;
         primitiveDictionary["SerializationVersion"]      = (object)serverCapability.SerializationVersion;
         primitiveDictionary["PSVersion"] = (object)serverCapability.PSVersion;
         this.SendDataAsync(RemotingEncoder.GenerateApplicationPrivateData(this.clientRunspacePoolId, applicationPrivateData1));
     }
 }
        /// <summary>
        /// Send a message with application private data to the client.
        /// </summary>
        /// <param name="applicationPrivateData">ApplicationPrivateData to send.</param>
        /// <param name="serverCapability">Server capability negotiated during initial exchange of remoting messages / session capabilities of client and server.</param>
        internal void SendApplicationPrivateDataToClient(PSPrimitiveDictionary applicationPrivateData, RemoteSessionCapability serverCapability)
        {
            // make server's PSVersionTable available to the client using ApplicationPrivateData
            PSPrimitiveDictionary applicationPrivateDataWithVersionTable =
                PSPrimitiveDictionary.CloneAndAddPSVersionTable(applicationPrivateData);

            // override the hardcoded version numbers with the stuff that was reported to the client during negotiation
            PSPrimitiveDictionary versionTable = (PSPrimitiveDictionary)applicationPrivateDataWithVersionTable[PSVersionInfo.PSVersionTableName];

            versionTable[PSVersionInfo.PSRemotingProtocolVersionName] = serverCapability.ProtocolVersion;
            versionTable[PSVersionInfo.SerializationVersionName]      = serverCapability.SerializationVersion;

            // Pass back the true PowerShell version to the client via application private data.
            versionTable[PSVersionInfo.PSVersionName] = PSVersionInfo.PSVersion;

            RemoteDataObject data = RemotingEncoder.GenerateApplicationPrivateData(
                _clientRunspacePoolId, applicationPrivateDataWithVersionTable);

            SendDataAsync(data);
        }