private string GetUserSettingsString(string key, string value)
        {
            IVsSettingsStore store = ReadOnlyUserSettings;

            Marshal.ThrowExceptionForHR(store.GetStringOrDefault(key, value, String.Empty, out string result));
            return(result);
        }
Пример #2
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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 public static byte[] GetByteArray(this IVsSettingsStore store, string collectionPath, string propertyName)
 {
     uint[] actualByteLength = { 0 };
     ErrorHandler.ThrowOnFailure(store.GetBinary(collectionPath, propertyName, 0, null, actualByteLength));
     byte[] binaryValue = new byte[actualByteLength[0]];
     ErrorHandler.ThrowOnFailure(store.GetBinary(collectionPath, propertyName, actualByteLength[0], binaryValue, actualByteLength));
     return(binaryValue);
 }
Пример #4
0
        public int GetReadOnlySettingsStore(uint scope, out IVsSettingsStore store)
        {
            if (scope != (uint)SettingsScope.UserSettings)
            {
                store = null;
                return(-1);
            }

            store = readOnlyStore;
            return(0);
        }
        public void BeforeEach()
        {
            _settingManagerMock = new Mock <IVsSettingsManager>();
            _uiShellMock        = new Mock <IVsUIShell>();
            int intValue           = 0;
            IVsSettingsStore store = Mock.Of <IVsSettingsStore>(
                ss => ss.GetIntOrDefault(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), out intValue) == 0);

            _settingManagerMock.Setup(sm => sm.GetReadOnlySettingsStore(It.IsAny <uint>(), out store)).Returns(0);
            GoogleCloudExtensionPackageTests.InitPackageMock(dte =>
            {
                Mock <IServiceProvider> providerMock = dte.As <IServiceProvider>();
                GoogleCloudExtensionPackageTests.SetupService <SVsSettingsManager, IVsSettingsManager>(
                    providerMock, _settingManagerMock);
                GoogleCloudExtensionPackageTests.SetupService <IVsUIShell, IVsUIShell>(providerMock, _uiShellMock);
            });
        }
        public static IEnumerable <string> GetPropertyNames(this IVsSettingsStore store, string collectionPath)
        {
            for (uint index = 0; ; index++)
            {
                string name;
                try
                {
                    if (ErrorHandler.Failed(store.GetPropertyName(collectionPath, index, out name)))
                    {
                        break;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    break;
                }

                yield return(name);
            }
        }
        public static IEnumerable <string> GetSubCollectionNames(this IVsSettingsStore store, string collectionPath)
        {
            // Don't get the count up-front. It's essentially an enumeration which is as expensive
            // as just looping until we get an error.

            for (uint index = 0; ; index++)
            {
                string subCollectionName;

                try
                {
                    if (ErrorHandler.Failed(store.GetSubCollectionName(collectionPath, index, out subCollectionName)))
                    {
                        break;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    break;
                }

                yield return(subCollectionName);
            }
        }
Пример #8
0
 public int GetReadOnlySettingsStore(uint scope, out IVsSettingsStore store) {
     store = ReadOnlyStore;
     return VSConstants.S_OK;
 }
Пример #9
0
 public SettingsStoreWrapper(IVsSettingsStore store)
 {
     _store = store;
 }
Пример #10
0
 public int GetReadOnlySettingsStore([ComAliasName("Microsoft.VisualStudio.Shell.Interop.VSSETTINGSSCOPE")] uint scope, out IVsSettingsStore store)
 {
     store = new StoreWrapper(inner.GetReadOnlySettingsStore((SettingsScope)scope));
     return(0);
 }
 public static bool PropertyExists(this IVsSettingsStore store, string collectionPath, string propertyName)
 {
     ErrorHandler.ThrowOnFailure(store.PropertyExists(collectionPath, propertyName, out int exists));
     return(exists != 0);
 }
Пример #12
0
 // Private constructor
 private Settings()
 {
     Shell.ThreadHelper.ThrowIfNotOnUIThread();
     this.Store = ReadOnlyConfigSettings;
 }
 public static __VsSettingsType GetPropertyType(this IVsSettingsStore store, string collectionPath, string propertyName)
 {
     ErrorHandler.ThrowOnFailure(store.GetPropertyType(collectionPath, propertyName, out var type));
     return((__VsSettingsType)type);
 }
Пример #14
0
 /// <summary>
 /// Internal constructor that takes the COM interface that provides the functionality of this class.
 /// </summary>
 /// <param name="settingsStore">COM interface wrapped by this class.</param>
 internal ShellSettingsStore(IVsSettingsStore settingsStore)
 {
     HelperMethods.CheckNullArgument(settingsStore, "settingsStore");
     this.settingsStore = settingsStore;
 }
Пример #15
0
 public int GetReadOnlySettingsStore(uint scope, out IVsSettingsStore store)
 {
     store = Stores[scope];
     return(Stores.ContainsKey(scope) ? VSConstants.S_OK : VSConstants.E_FAIL);
 }
Пример #16
0
 /// <summary>
 /// Internal constructor that takes the COM interface that provides the functionality of this class.
 /// </summary>
 /// <param name="settingsStore">COM interface wrapped by this class.</param>
 internal ShellSettingsStore(IVsSettingsStore settingsStore)
 {
     HelperMethods.CheckNullArgument(settingsStore, "settingsStore");
     this.settingsStore = settingsStore;
 }
 public static ulong GetUint64(this IVsSettingsStore store, string collectionPath, string propertyName)
 {
     ErrorHandler.ThrowOnFailure(store.GetUnsignedInt64(collectionPath, propertyName, out var value));
     return(value);
 }
Пример #18
0
 public int GetReadOnlySettingsStore(uint scope, out IVsSettingsStore store)
 {
     store = ReadOnlyStore;
     return(VSConstants.S_OK);
 }
 public static bool CollectionExists(this IVsSettingsStore store, string collectionPath)
 {
     ErrorHandler.ThrowOnFailure(store.CollectionExists(collectionPath, out int exists));
     return(exists != 0);
 }
Пример #20
0
 public int GetReadOnlySettingsStore([ComAliasName("Microsoft.VisualStudio.Shell.Interop.VSSETTINGSSCOPE")]uint scope, out IVsSettingsStore store)
 {
     store = new StoreWrapper(inner.GetReadOnlySettingsStore((SettingsScope)scope));
     return 0;
 }
 public SettingsStoreWrapper(IVsSettingsStore store)
 {
     _store = store;
 }