/// <summary> /// Load a list of UIContext items from the settings store. /// </summary> /// <param name="settingsStore"></param> /// <param name="list"></param> /// <param name="name"></param> private void LoadContextIDList(IVsSettingsStore settingsStore, ObservableCollection <UIContextInformation> list, string name) { ThreadHelper.ThrowIfNotOnUIThread(); string collectionRoot = SettingsRoot + "\\" + name; settingsStore.CollectionExists(collectionRoot, out var exists); if (exists != 0) { settingsStore.GetPropertyCount(collectionRoot, out var contextCount); for (uint iContext = 0; iContext < contextCount; iContext++) { if (ErrorHandler.Succeeded(settingsStore.GetPropertyName(collectionRoot, iContext, out var guidString))) { Guid contextGuid = new Guid(guidString); if (ErrorHandler.Succeeded(selectionMonitor.GetCmdUIContextCookie(ref contextGuid, out var contextID))) { if (contextIDNames.ContainsKey(contextID)) { list.Add(contextIDNames[contextID]); if (contextIDNames[contextID].Name.StartsWith("#") || contextIDNames[contextID].Name.StartsWith("resource=")) { // if the name is a resource, use the name we found from the last session if (ErrorHandler.Succeeded(settingsStore.GetString(collectionRoot, guidString, out var contextName))) { contextIDNames[contextID].Name = contextName; } } } } } } } }
public static string GetString(this IVsSettingsStore store, string collectionPath, string propertyName) { ErrorHandler.ThrowOnFailure(store.GetString(collectionPath, propertyName, out var value)); return(value); }