Exemplo n.º 1
0
        /// <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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public bool CollectionExists(string collection)
        {
            int exists;
            int hr = _store.CollectionExists(collection, out exists);

            return(ErrorHandler.Succeeded(hr) && exists == 1);
        }
Exemplo n.º 3
0
        public bool CollectionExists(string collection)
        {
            return(NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                var hr = _store.CollectionExists(collection, out var exists);
                return ErrorHandler.Succeeded(hr) && exists == 1;
            }));
        }
 public static bool CollectionExists(this IVsSettingsStore store, string collectionPath)
 {
     ErrorHandler.ThrowOnFailure(store.CollectionExists(collectionPath, out int exists));
     return(exists != 0);
 }