示例#1
0
        private IEnumerable <EngineRegistration> GetEngineRegistrations()
        {
            List <EngineRegistration> registrations = new List <EngineRegistration>();

            // Check all engine registrations to find ones that use the debug adapter host
            using (RegistryKey enginesKey = this.package.ApplicationRegistryRoot.OpenSubKey("AD7Metrics\\Engine"))
            {
                if (enginesKey != null)
                {
                    foreach (string engineId in enginesKey.GetSubKeyNames())
                    {
                        using (RegistryKey engineKey = enginesKey.OpenSubKey(engineId))
                        {
                            Guid?clsid = engineKey.GetGuidValue("CLSID");
                            if (clsid == null || clsid.Value != AdapterHostClsid)
                            {
                                // CLSID wasn't specified, or doesn't point to the debug adapter host, so skip it
                                continue;
                            }

                            Guid?id = GuidHelper.TryParseGuid(engineId);
                            if (id == null)
                            {
                                continue;
                            }

                            // It's common to have multiple registrations for the same engine, where one is for launch
                            //  and the other is for attach - try to detect this so we can tell the values apart.
                            string engineName = engineKey.GetValue("Name") as string;
                            if (engineKey.GetBoolValue("Attach") != false && engineKey.GetGuidValue("PortSupplier") != null)
                            {
                                // If the registration specifies true for "Attach" and includes a port supplier guid, consider
                                //  it an "attach" registration
                                engineName = engineName + " [Attach]";
                            }

                            registrations.Add(new EngineRegistration(engineName, id.Value));
                        }
                    }
                }
            }

            return(registrations);
        }