コード例 #1
0
        private static SupportedVersionList ExtractSupportedVersionList(Runspace newRunspace)
        {
            PSPrimitiveDictionary applicationPrivateData = newRunspace.GetApplicationPrivateData();
            object obj = applicationPrivateData["SupportedVersions"];

            return(SupportedVersionList.Parse((obj != null) ? obj.ToString() : string.Empty));
        }
コード例 #2
0
        public static SupportedVersionList Parse(string list)
        {
            SupportedVersionList result = null;

            try
            {
                result = new SupportedVersionList((list != null) ? list.ToString() : string.Empty);
            }
            catch (ArgumentException ex)
            {
                throw new SupportedVersionListFormatException(new LocalizedString(ex.Message));
            }
            return(result);
        }
コード例 #3
0
        protected override Runspace CreateRunspace(PSHost host)
        {
            Runspace runspace = base.CreateRunspace(host);

            if (!string.IsNullOrEmpty(this.clientVersion))
            {
                SupportedVersionList supportedVersionList = MonadRemoteRunspaceFactory.ExtractSupportedVersionList(runspace);
                if (supportedVersionList.IsSupported(this.clientVersion))
                {
                    runspace.Dispose();
                    throw new VersionMismatchException(Strings.VersionMismatchDuringCreateRemoteRunspace, supportedVersionList);
                }
            }
            return(runspace);
        }
コード例 #4
0
        public static SupportedVersionList TestConnection(Uri uri, string shell, PSCredential credential, AuthenticationMechanism mechanism, int maxRedirectionCount, bool skipCertificateCheck)
        {
            WSManConnectionInfo wsmanConnectionInfo = new WSManConnectionInfo(uri, shell, credential);

            wsmanConnectionInfo.AuthenticationMechanism           = mechanism;
            wsmanConnectionInfo.MaximumConnectionRedirectionCount = maxRedirectionCount;
            if (skipCertificateCheck)
            {
                wsmanConnectionInfo.SkipCACheck         = true;
                wsmanConnectionInfo.SkipCNCheck         = true;
                wsmanConnectionInfo.SkipRevocationCheck = true;
            }
            Runspace             runspace = null;
            SupportedVersionList result   = null;
            Runspace             runspace2;

            runspace = (runspace2 = RunspaceFactory.CreateRunspace(wsmanConnectionInfo));
            try
            {
                lock (MonadRemoteRunspaceFactory.syncObject)
                {
                    MonadRemoteRunspaceFactory.runspaceInstances.Add(runspace);
                }
                runspace.Open();
                result = MonadRemoteRunspaceFactory.ExtractSupportedVersionList(runspace);
            }
            finally
            {
                if (runspace2 != null)
                {
                    ((IDisposable)runspace2).Dispose();
                }
            }
            lock (MonadRemoteRunspaceFactory.syncObject)
            {
                MonadRemoteRunspaceFactory.runspaceInstances.Remove(runspace);
            }
            return(result);
        }
コード例 #5
0
 // Token: 0x06001142 RID: 4418 RVA: 0x00034DB1 File Offset: 0x00032FB1
 public VersionMismatchException(LocalizedString message, SupportedVersionList versionList) : base(message)
 {
     this.SupportedVersionList = versionList;
 }