Esempio n. 1
0
        internal static RemoteSessionCapability GetSessionCapability(object data)
        {
            RemoteSessionCapability sessionCapability = data is PSObject psObject ? new RemoteSessionCapability(RemotingDestination.InvalidDestination, RemotingDecoder.GetPropertyValue <Version>(psObject, "protocolversion"), RemotingDecoder.GetPropertyValue <Version>(psObject, "PSVersion"), RemotingDecoder.GetPropertyValue <Version>(psObject, "SerializationVersion")) : throw new PSRemotingDataStructureException(PSRemotingErrorId.CantCastRemotingDataToPSObject, new object[1]
            {
                (object)data.GetType().FullName
            });

            if (psObject.Properties["TimeZone"] != null)
            {
                byte[] propertyValue = RemotingDecoder.GetPropertyValue <byte[]>(psObject, "TimeZone");
                sessionCapability.TimeZone = RemoteSessionCapability.ConvertFromByteToTimeZone(propertyValue);
            }
            return(sessionCapability);
        }
Esempio n. 2
0
        internal static RemoteSessionCapability GetSessionCapability(object data)
        {
            PSObject psObject = data as PSObject;

            if (psObject == null)
            {
                throw new PSRemotingDataStructureException(RemotingErrorIdStrings.CantCastRemotingDataToPSObject, new object[] { data.GetType().FullName });
            }
            Version propertyValue = GetPropertyValue <Version>(psObject, "protocolversion");
            Version psVersion     = GetPropertyValue <Version>(psObject, "PSVersion");
            Version serVersion    = GetPropertyValue <Version>(psObject, "SerializationVersion");
            RemoteSessionCapability capability = new RemoteSessionCapability(RemotingDestination.InvalidDestination, propertyValue, psVersion, serVersion);

            if (psObject.Properties["TimeZone"] != null)
            {
                byte[] buffer = GetPropertyValue <byte[]>(psObject, "TimeZone");
                capability.TimeZone = RemoteSessionCapability.ConvertFromByteToTimeZone(buffer);
            }
            return(capability);
        }