public static bool IsEnabled(string identifier) { string raw = _readStore.GetString(_name, _identifierKey, string.Empty); if (string.IsNullOrEmpty(raw)) { return(false); } string[] identifiers = raw.Split(new[] { _separator }, StringSplitOptions.RemoveEmptyEntries); return(identifiers.Contains(identifier)); }
public string ReadStringData(string key) { try { if (!_readOnlySettingsStore.CollectionExists(tasCollectionPath)) { _logger.Error($"Attempted to read user settings store value under \"{tasCollectionPath}\" but no such collection path exists"); return(null); } if (_readOnlySettingsStore.PropertyExists(tasCollectionPath, key)) { return(_readOnlySettingsStore.GetString(tasCollectionPath, key)); } else { _logger.Error($"Attempted to read user settings store value for \"{key}\" but no such property exists"); return(null); } } catch (Exception ex) { _logger.Error(ex.Message); return(null); } }
/// <summary> /// Hydrates the properties from the registry asyncronously. /// </summary> public virtual async Task LoadAsync() { ShellSettingsManager manager = await _settingsManager.GetValueAsync(); SettingsStore settingsStore = manager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (!settingsStore.CollectionExists(CollectionName)) { return; } foreach (PropertyInfo property in GetOptionProperties()) { try { string serializedProp = settingsStore.GetString(CollectionName, property.Name); object value = DeserializeValue(serializedProp, property.PropertyType); property.SetValue(this, value); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex); } } }
/// <summary> /// Hydrates the properties from the registry asyncronously. /// </summary> public virtual async Task LoadAsync() { ShellSettingsManager manager = await _settingsManager.GetValueAsync(); SettingsStore settingsStore = manager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (!settingsStore.CollectionExists(CollectionName)) { return; } foreach (PropertyInfo property in GetOptionProperties()) { try { var serializedProp = settingsStore.GetString(CollectionName, property.Name, default); var value = DeserializeValue(serializedProp, property.PropertyType); property.SetValue(this, value); } catch { // Do nothing here } } }
protected override void LoadProperty(SettingsStore store) { var value = store.GetString(CollectionName, nameof(TargetLanguage), "Lua"); if (value == "Lua") { TargetLanguage = TargetLanguages.Lua; } else if (value == "JavaScript") { TargetLanguage = TargetLanguages.JavaScript; } else { TargetLanguage = TargetLanguages.Lua; } m_target_lang_string = value; // çº æ£ if (TargetLanguage == TargetLanguages.Lua) { m_target_lang_string = "Lua"; } }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { CompareDirectoriesCommand.Initialize(this); base.Initialize(); using (ServiceProvider serviceProvider = new ServiceProvider((IServiceProvider)(Package.GetGlobalService(typeof(IServiceProvider))))) { SettingsManager settingsManager = new ShellSettingsManager(serviceProvider); SettingsStore settingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (settingsStore.CollectionExists(FilterSettings)) { IEnumerable <string> propertyNames = settingsStore.GetPropertyNames(FilterSettings); foreach (string propertyName in propertyNames) { var filter = settingsStore.GetString(FilterSettings, propertyName, null); if (filter != null) { CommonFilters.Add(filter); } } } } if (CommonFilters.Count == 0) { CommonFilters.Add("-*.dll;-*.pdb;-*.obj;-*.exe;-*.vsix;-.vs\\*;-*obj\\*;-*bin\\*;-.git\\*;-packages\\*"); CommonFilters.Add("*.cs;*.vb;*.c;*.cpp;*.h"); CommonFilters.Add(string.Empty); } }
/// <summary> /// Hydrates the properties from the registry asyncronously. /// </summary> public virtual async Task LoadAsync() { ShellSettingsManager manager = await _settingsManager.GetValueAsync(); SettingsStore settingsStore = manager.GetReadOnlySettingsStore(SettingsScope.UserSettings); HashSet <string> testedCollections = new HashSet <string>(); bool DoesCollectionExist(string collectionName) { if (testedCollections.Contains(collectionName)) { return(true); } if (settingsStore.CollectionExists(collectionName)) { testedCollections.Add(collectionName); return(true); } return(false); } foreach (PropertyInfo property in GetOptionProperties()) { try { var collectionNameAttribute = property.GetCustomAttribute <OverrideCollectionNameAttribute>(); var collectionName = collectionNameAttribute?.CollectionName ?? this.CollectionName; if (!DoesCollectionExist(collectionName)) { continue; } var overrideDataTypeAttribute = property.GetCustomAttribute <OverrideDataTypeAttribute>(); var dataType = overrideDataTypeAttribute?.SettingDataType ?? SettingDataType.Serialized; switch (dataType) { case SettingDataType.Serialized: var serializedProp = settingsStore.GetString(collectionName, property.Name, default); var value = DeserializeValue(serializedProp, property.PropertyType); property.SetValue(this, value); break; case SettingDataType.Bool: var boolValue = settingsStore.GetBoolean(collectionName, property.Name, false); property.SetValue(this, boolValue); break; default: throw new ArgumentOutOfRangeException(); } } catch { // Do nothing here } } }
private static string GetStringOption(SettingsStore store, string catelogName, string optionName) { if (store == null || !store.CollectionExists(COLLECTION_PATH) || !store.PropertyExists(COLLECTION_PATH, CombineCatelogAndOptionName(catelogName, optionName))) { return(null); } return(store.GetString(COLLECTION_PATH, CombineCatelogAndOptionName(catelogName, optionName))); }
public IEnumerable <AutoLoadPackage> GetAutoLoadPackages() { foreach (string autoLoadContextGuidString in _configurationStore.GetSubCollectionNames(_autoLoadPackagesPath)) { //Each path here is a context GUID Guid contextGuid = Guid.Empty; if (!Guid.TryParse(autoLoadContextGuidString, out contextGuid)) { continue; } string packagesPath = Path.Combine(_autoLoadPackagesPath, autoLoadContextGuidString); string contextName = GetUIContextName(autoLoadContextGuidString); bool isRuleBasedUIContext = IsRuleBasedUIContext(autoLoadContextGuidString); string uiContextExpression = string.Empty; if (isRuleBasedUIContext) { string rulePath = Path.Combine(_uIContextRulesPath, autoLoadContextGuidString); var expression = new StringBuilder(); foreach (string expressionName in _configurationStore.GetPropertyNames(rulePath)) { if (expressionName != "" && expressionName != "Expression" && expressionName != "Delay") { expression.Append(_configurationStore.GetString(rulePath, expressionName) + "|"); } } uiContextExpression = expression.ToString(); } foreach (string packageGuidString in _configurationStore.GetPropertyNames(packagesPath)) { Guid packageGuid = Guid.Empty; if (Guid.TryParse(packageGuidString, out packageGuid)) { yield return(new AutoLoadPackage(packageGuid, contextGuid, contextName, isRuleBasedUIContext, uiContextExpression, _configurationStore)); } } } }
public MRUHelper(string path) { ExternalSettingsManager externalSettingsManager = ExternalSettingsManager.CreateForApplication(path); settingsStore = externalSettingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); foreach (string name in settingsStore.GetPropertyNames(@"MRUItems\{a9c4a31f-f9cb-47a9-abc0-49ce82d0b3ac}\Items")) { string value = settingsStore.GetString(@"MRUItems\{a9c4a31f-f9cb-47a9-abc0-49ce82d0b3ac}\Items", name); Console.WriteLine("Property name: {0}, value: {1}", name, value.Split('|')[0]); recentProjectsPaths.Add(value.Split('|')[0]); } }
private static Color?GetColorOption(SettingsStore store, string catelogName, string optionName) { if (store == null || !store.CollectionExists(COLLECTION_PATH) || !store.PropertyExists(COLLECTION_PATH, CombineCatelogAndOptionName(catelogName, optionName))) { return(null); } var rgb = store.GetString(COLLECTION_PATH, CombineCatelogAndOptionName(catelogName, optionName)).Split(',').Select(x => Int32.Parse(x)).ToList(); return(Color.FromArgb(rgb[0], rgb[1], rgb[2])); }
private string GetLastUsed() { try { SettingsStore store = _settings.GetReadOnlySettingsStore(SettingsScope.UserSettings); return(store.GetString("PackageInstaller", "type", null)); } catch (Exception ex) { Logger.Log(ex); return(null); } }
public static String GetQuickRefFontFamily() { try { ThreadHelper.ThrowIfNotOnUIThread(); return(SettingsStore.GetString(CollectionName, QuickRefFontFamilyPropertyName, DefaultQuickRefFontFamily)); } catch (ArgumentException) { return(DefaultQuickRefFontFamily); } }
protected override void LoadProperty(SettingsStore store) { var value = store.GetString(CollectionName, nameof(ProjectTeam), "None"); if (value == "LW") { ProjectTeam = ProjectTeamTypes.LW; } else { ProjectTeam = ProjectTeamTypes.None; } }
/// <summary> /// Hydrates the properties from the registry asyncronously. /// </summary> public virtual async Task LoadAsync() { ShellSettingsManager manager = await _settingsManager.GetValueAsync().ConfigureAwait(true); SettingsStore settingsStore = manager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (!settingsStore.CollectionExists(CollectionName)) { return; } #if DEBUG_OPTION_VALUES_LOAD_SAVE Debug.WriteLine($"LoadAsync<{typeof(T).Name}>()"); Debug.WriteLine($"GetPropertyCount = {settingsStore.GetPropertyCount(CollectionName)}"); Debug.WriteLine($"GetPropertyCount = {settingsStore.GetPropertyCount(CollectionName)}"); //var pnv = settingsStore.GetPropertyNamesAndValues(CollectionName); var pn = settingsStore.GetPropertyNames(CollectionName); foreach (var n in pn) { Debug.WriteLine($"Property: Name={n} Type = {settingsStore.GetPropertyType(CollectionName, n).ToString()}"); } #endif var propertiesToSerialize = GetOptionProperties(); foreach (PropertyInfo property in propertiesToSerialize) { if (!settingsStore.PropertyExists(CollectionName, property.Name)) { #if DEBUG_OPTION_VALUES_LOAD_SAVE Debug.WriteLine($"Skipping property {property.Name}. Not found in settings store"); #endif property.SetValue(this, property.GetValue(this)); continue; } try { string serializedProp = settingsStore.GetString(CollectionName, property.Name); object value = DeserializeValue(serializedProp, property.PropertyType); property.SetValue(this, value); #if DEBUG_OPTION_VALUES_LOAD_SAVE Debug.WriteLine($"{property.Name} = {property.GetValue(this)} | value = {value}"); #endif } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } #if DEBUG_OPTION_VALUES_LOAD_SAVE Debug.WriteLine($"LoadAsync<{typeof(T).Name}>() finished ==================================="); #endif }
public AutoLoadPackage(Guid packageGuid, Guid contextGuid, string contextName, bool isRuleBasedUIContext, string contextTerms, SettingsStore configurationStore) { PackageGuid = packageGuid; AutoLoadContextGuid = contextGuid; AutoLoadContextName = contextName; IsRuleBasedUIContext = isRuleBasedUIContext; UIContextTerms = contextTerms; string packageInfoPath = Path.Combine(_packagesPath, packageGuid.ToString("B")); string autoLoadConfigurationPath = Path.Combine(_autoLoadPackagesPath, contextGuid.ToString("B")); if (configurationStore.CollectionExists(packageInfoPath)) { PackageName = configurationStore.GetString(packageInfoPath, string.Empty, "Unknown").Split(',')[0]; string moduleName = configurationStore.GetString(packageInfoPath, "Class", null) ?? Path.GetFileName(configurationStore.GetString(packageInfoPath, "InProcServer32", string.Empty)); ModuleName = moduleName.Split(',')[0]; IsAsyncPackage = configurationStore.GetBoolean(packageInfoPath, "AllowsBackgroundLoad", false); } if (configurationStore.CollectionExists(autoLoadConfigurationPath)) { uint autoLoadFlags = (uint)PackageAutoLoadFlags.None; try { autoLoadFlags = configurationStore.GetUInt32(autoLoadConfigurationPath, packageGuid.ToString("B"), 0); } catch (Exception) { //Do not do anyting. Use none as flag // Apparently user feed package "bb4bf712-fcf7-4d17-83bb-93e6478b4e5d" specified a string in the pkgdef.. } bool backgroundLoad = ((autoLoadFlags & (uint)PackageAutoLoadFlags.BackgroundLoad) == (uint)PackageAutoLoadFlags.BackgroundLoad); IsAsyncForUIContext = IsAsyncPackage && backgroundLoad; } }
private (string container, string vsDbg) GetSettings() { const string collectionPath = nameof(AttachToDockerContainerDialog); ThreadHelper.ThrowIfNotOnUIThread(); SettingsStore.CollectionExists(collectionPath, out int exists); if (exists != 1) { SettingsStore.CreateCollection(collectionPath); } SettingsStore.GetString(collectionPath, "container", out string container); SettingsStore.GetString(collectionPath, "vsdbg", out string vsdbg); return(container, vsdbg); }
private string GetSettingsPath() { var settingName = "VisualStudioProjectsLocation"; SettingsManager sm = new ShellSettingsManager(ServiceProvider.GlobalProvider); SettingsStore ss = sm.GetReadOnlySettingsStore(SettingsScope.UserSettings); string setting = ""; try { setting = ss.GetString("", settingName); } catch (Exception ex) { string collection = ""; foreach (string s in ss.GetPropertyNames("")) { collection += s + "\r\n"; } MessageBox.Show($"Cannot find {settingName} in {collection}"); } return(Environment.ExpandEnvironmentVariables(setting)); }
private PythonInterpreterFactoryWithDatabase LoadUserDefinedInterpreter(SettingsStore store, string guid) { // PythonInterpreters\ // Id\ // Description // InterpreterPath // WindowsInterpreterPath // Architecture // Version // PathEnvironmentVariable Guid id; string collection; if (Guid.TryParse(guid, out id) && store.CollectionExists((collection = PythonInterpreterKey + "\\" + id.ToString("B")))) { var path = store.GetString(collection, PathKey, string.Empty); var winPath = store.GetString(collection, WindowsPathKey, string.Empty); var libPath = store.GetString(collection, LibraryPathKey, string.Empty); var arch = store.GetString(collection, ArchitectureKey, string.Empty); var version = store.GetString(collection, VersionKey, string.Empty); var pathEnvVar = store.GetString(collection, PathEnvVarKey, string.Empty); var description = store.GetString(collection, DescriptionKey, string.Empty); return(InterpreterFactoryCreator.CreateInterpreterFactory( new InterpreterFactoryCreationOptions { LanguageVersionString = version, Id = id, Description = description, InterpreterPath = path, WindowInterpreterPath = winPath, LibraryPath = libPath, PathEnvironmentVariableName = pathEnvVar, ArchitectureString = arch, WatchLibraryForNewModules = true } )); } return(null); }
public override void LoadSettingsFromStorage() { SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); SettingsStore settingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (!settingsStore.CollectionExists(CollectionName)) { return; } foreach (PropertyInfo property in GetOptionProperties()) { try { string serializedProp = settingsStore.GetString(CollectionName, property.Name); object value = DeserializeValue(serializedProp, property.PropertyType); property.SetValue(this, value); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex); } } }
private static IEnumerable <int> GetGuideColumns(SettingsStore userSettings) { var guides = userSettings.GetString("Text Editor", "Guides", string.Empty).Trim(); if (string.IsNullOrEmpty(guides) || !guides.StartsWith("RGB(", StringComparison.Ordinal)) { yield break; } int index = guides.IndexOf(')', 4); if (index < 0) { yield break; } foreach (var s in guides.Substring(index + 1).Split(',')) { if (int.TryParse(s, out int column) && column >= 0) { yield return(column); } } }
private PythonInterpreterFactoryWithDatabase LoadUserDefinedInterpreter(SettingsStore store, string guid) { // PythonInterpreters\ // Id\ // Description // InterpreterPath // WindowsInterpreterPath // Architecture // Version // PathEnvironmentVariable Guid id; string collection; if (Guid.TryParse(guid, out id) && store.CollectionExists((collection = PythonInterpreterKey + "\\" + id.ToString("B")))) { var path = store.GetString(collection, PathKey, string.Empty); var winPath = store.GetString(collection, WindowsPathKey, string.Empty); var libPath = store.GetString(collection, LibraryPathKey, string.Empty); var arch = store.GetString(collection, ArchitectureKey, string.Empty); var version = store.GetString(collection, VersionKey, string.Empty); var pathEnvVar = store.GetString(collection, PathEnvVarKey, string.Empty); var description = store.GetString(collection, DescriptionKey, string.Empty); return InterpreterFactoryCreator.CreateInterpreterFactory( new InterpreterFactoryCreationOptions { LanguageVersionString = version, Id = id, Description = description, InterpreterPath = path, WindowInterpreterPath = winPath, LibraryPath = libPath, PathEnvironmentVariableName = pathEnvVar, ArchitectureString = arch, WatchLibraryForNewModules = true } ); } return null; }
protected T ReadSetting <T>(SettingsStore store, string collectionName, string name) { var serializedProp = store.GetString(collectionName, name); return((T)DeserializeValue(serializedProp)); }
public int GetString([ComAliasName("OLE.LPCOLESTR")] string collectionPath, [ComAliasName("OLE.LPCOLESTR")] string propertyName, out string value) { value = inner.GetString(collectionPath, propertyName); return(0); }
private IPythonInterpreterFactoryProvider[] LoadProviders( SettingsStore store, IServiceProvider serviceProvider ) { var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase); var catalog = new List<ComposablePartCatalog>(); if (store.CollectionExists(SuppressFactoryProvidersCollection)) { return new IPythonInterpreterFactoryProvider[0]; } if (store.CollectionExists(FactoryProvidersCollection)) { foreach (var idStr in store.GetSubCollectionNames(FactoryProvidersCollection)) { var key = FactoryProvidersCollection + "\\" + idStr; LoadOneProvider( store.GetString(key, FactoryProviderCodeBaseSetting, ""), seen, catalog, _activityLog ); } } foreach (var baseKey in new[] { Registry.CurrentUser, Registry.LocalMachine }) { using (var key = baseKey.OpenSubKey(FactoryProvidersRegKey)) { if (key != null) { foreach (var idStr in key.GetSubKeyNames()) { using (var subkey = key.OpenSubKey(idStr)) { if (subkey != null) { LoadOneProvider( subkey.GetValue(FactoryProviderCodeBaseSetting, "") as string, seen, catalog, _activityLog ); } } } } } } if (!catalog.Any()) { LoadOneProvider( typeof(CPythonInterpreterFactoryConstants).Assembly.Location, seen, catalog, _activityLog ); } const string FailedToImportMessage = "Failed to import factory providers"; var providers = new List<IPythonInterpreterFactoryProvider>(); var serviceProviderProvider = new MockExportProvider(); if (serviceProvider != null) { serviceProviderProvider.SetExport(typeof(SVsServiceProvider), () => serviceProvider); } foreach (var part in catalog) { var container = new CompositionContainer(part, serviceProviderProvider); try { foreach (var provider in container.GetExports<IPythonInterpreterFactoryProvider>()) { if (provider.Value != null) { providers.Add(provider.Value); } } } catch (CompositionException ex) { LogException(_activityLog, FailedToImportMessage, null, ex, ex.Errors); } catch (ReflectionTypeLoadException ex) { LogException(_activityLog, FailedToImportMessage, null, ex, ex.LoaderExceptions); } catch (Exception ex) { LogException(_activityLog, FailedToImportMessage, null, ex); } } return providers.ToArray(); }
private IPythonInterpreterFactoryProvider[] LoadProviders( SettingsStore store, IServiceProvider serviceProvider ) { var seen = new HashSet <string>(StringComparer.OrdinalIgnoreCase); var catalog = new List <ComposablePartCatalog>(); if (store.CollectionExists(SuppressFactoryProvidersCollection)) { return(new IPythonInterpreterFactoryProvider[0]); } if (store.CollectionExists(FactoryProvidersCollection)) { foreach (var idStr in store.GetSubCollectionNames(FactoryProvidersCollection)) { var key = FactoryProvidersCollection + "\\" + idStr; LoadOneProvider( store.GetString(key, FactoryProviderCodeBaseSetting, ""), seen, catalog, _activityLog ); } } foreach (var baseKey in new[] { Registry.CurrentUser, Registry.LocalMachine }) { using (var key = baseKey.OpenSubKey(FactoryProvidersRegKey)) { if (key != null) { foreach (var idStr in key.GetSubKeyNames()) { using (var subkey = key.OpenSubKey(idStr)) { if (subkey != null) { LoadOneProvider( subkey.GetValue(FactoryProviderCodeBaseSetting, "") as string, seen, catalog, _activityLog ); } } } } } } if (!catalog.Any()) { LoadOneProvider( typeof(CPythonInterpreterFactoryConstants).Assembly.Location, seen, catalog, _activityLog ); } const string FailedToImportMessage = "Failed to import factory providers"; var providers = new List <IPythonInterpreterFactoryProvider>(); var serviceProviderProvider = new MockExportProvider(); if (serviceProvider != null) { serviceProviderProvider.SetExport(typeof(SVsServiceProvider), () => serviceProvider); } foreach (var part in catalog) { var container = new CompositionContainer(part, serviceProviderProvider); try { foreach (var provider in container.GetExports <IPythonInterpreterFactoryProvider>()) { if (provider.Value != null) { providers.Add(provider.Value); } } } catch (CompositionException ex) { LogException(_activityLog, FailedToImportMessage, null, ex, ex.Errors); } catch (ReflectionTypeLoadException ex) { LogException(_activityLog, FailedToImportMessage, null, ex, ex.LoaderExceptions); } catch (Exception ex) { LogException(_activityLog, FailedToImportMessage, null, ex); } } return(providers.ToArray()); }
/// <summary> /// Populates the maps that map from name -> scope info and GUID -> scope info /// </summary> private void PopulateScopeMaps() { ShellSettingsManager settingsManager = new ShellSettingsManager(this.serviceProvider); SettingsStore settingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.Configuration); // First build map of all registered scopes if (settingsStore.CollectionExists(KeyBindingTableRegKeyName)) { int itemCount = settingsStore.GetSubCollectionCount(KeyBindingTableRegKeyName); foreach (string str in settingsStore.GetSubCollectionNames(KeyBindingTableRegKeyName)) { string collectionName = Path.Combine(KeyBindingTableRegKeyName, str); Guid scopeId; if (!Guid.TryParse(str, out scopeId)) { continue; } Guid owningPackage; uint resourceId; bool allowNavKeyBinding = false; if (scopeId == VSConstants.GUID_VSStandardCommandSet97) { owningPackage = CLSID_VsEnvironmentPackage; resourceId = ID_Intl_Base + 18; } else { if (!settingsStore.PropertyExists(collectionName, PackageRegPropertyName)) { continue; } if (!Guid.TryParse(settingsStore.GetString(collectionName, PackageRegPropertyName), out owningPackage)) { continue; } string resIdString = settingsStore.GetString(collectionName, string.Empty); if (resIdString.StartsWith("#")) { resIdString = resIdString.Substring(1); } if (!uint.TryParse(resIdString, out resourceId)) { continue; } if (settingsStore.PropertyExists(collectionName, AllowNavKeyBindingPropertyName)) { allowNavKeyBinding = settingsStore.GetUInt32(collectionName, AllowNavKeyBindingPropertyName) == 0 ? false : true; } } string scopeName; if (!ErrorHandler.Succeeded(Shell.LoadPackageString(ref owningPackage, resourceId, out scopeName))) { continue; } KeybindingScope scopeInfo = new KeybindingScope(scopeName, scopeId, allowNavKeyBinding); this.scopeGuidToScopeInfoMap[scopeId] = scopeInfo; this.scopeNameToScopeInfoMap[scopeName] = scopeInfo; } } IVsEnumGuids scopeEnum = UIShell.EnumKeyBindingScopes(); // Random GUID the shell also skips ("Source Code Text Editor" scope) Guid toSkip = new Guid("{72F42A10-B1C5-11d0-A8CD-00A0C921A4D2}"); Guid[] scopes = new Guid[1]; uint fetched = 0; while (scopeEnum.Next((uint)scopes.Length, scopes, out fetched) == VSConstants.S_OK && fetched != 0) { // We already have info for this scope if (scopeGuidToScopeInfoMap.ContainsKey(scopes[0])) { continue; } // The shell skips this as a possible binding scope if (scopes[0] == toSkip) { continue; } string path = Path.Combine("Editors", scopes[0].ToString("B")); // If it isn't a registered scope, see if it is an editor factory if (!settingsStore.CollectionExists(path)) { continue; } if (!settingsStore.PropertyExists(path, PackageRegPropertyName)) { continue; } Guid packageGuid; if (!Guid.TryParse(settingsStore.GetString(path, PackageRegPropertyName), out packageGuid)) { continue; } if (!settingsStore.PropertyExists(path, DisplayNameRegPropertyName)) { continue; } string displayNameResIdStr = settingsStore.GetString(path, DisplayNameRegPropertyName); if (displayNameResIdStr.StartsWith("#")) { displayNameResIdStr = displayNameResIdStr.Substring(1); } uint displayNameResId; if (!uint.TryParse(displayNameResIdStr, out displayNameResId)) { continue; } string displayName; if (!ErrorHandler.Succeeded(shell.LoadPackageString(ref packageGuid, displayNameResId, out displayName))) { continue; } // NOTE: Is false the right default value? KeybindingScope scopeInfo = new KeybindingScope(displayName, scopes[0], allowNavKeyBinding: false); this.scopeGuidToScopeInfoMap[scopes[0]] = scopeInfo; this.scopeNameToScopeInfoMap[displayName] = scopeInfo; } }