Exemplo n.º 1
0
        // Must happen on the UI thread.
        private IEnumerable <IOmniBoxItemsSource> CreateSources()
        {
            var settingsManager = new ShellSettingsManager(this.shellServiceProvider);
            var settingsStore   = settingsManager.GetReadOnlySettingsStore(SettingsScope.Configuration);

            if (settingsStore.CollectionExists(QuickLaunchStoreName))
            {
                foreach (var searchProviderId in settingsStore.GetSubCollectionNames(QuickLaunchStoreName))
                {
                    var collectionPath = $@"{QuickLaunchStoreName}\{searchProviderId}";

                    if (settingsStore.PropertyExists(collectionPath, PackageKeyName) &&
                        (settingsStore.GetPropertyType(collectionPath, PackageKeyName) == SettingsType.String))
                    {
                        var packageId = settingsStore.GetString(collectionPath, PackageKeyName);

                        if ((packageId != null) &&
                            Guid.TryParse(packageId, out var packageGuid) &&
                            Guid.TryParse(searchProviderId, out var searchProviderGuid))
                        {
                            var searchProvider = VsShellUtilities
                                                 .TryGetPackageExtensionPoint <IVsSearchProvider, IVsSearchProvider>(packageGuid, searchProviderGuid);

                            if ((searchProvider != null) && (searchProvider.Category.ToString() != MREProviderCategory))
                            {
                                yield return(new QuickLaunchItemsSource(searchProvider));
                            }
                        }
                    }
                }
            }
        }