示例#1
0
        private void SaveGroupsForSolution(string solutionName = null, IList <DocumentGroup> groups = null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (solutionName == null)
            {
                solutionName = SolutionName;
            }
            if (string.IsNullOrWhiteSpace(solutionName))
            {
                return;
            }

            if (groups == null)
            {
                groups = Groups;
            }

            var settingsMgr = new ShellSettingsManager(ServiceProvider);
            var store       = settingsMgr.GetWritableSettingsStore(SettingsScope.UserSettings);

            string projectKeyHash   = GetHashString(solutionName);
            string projectGroupsKey = string.Format(ProjectGroupsKeyPlaceholder, projectKeyHash);

            if (store.CollectionExists(projectGroupsKey))
            {
                store.DeleteCollection(projectGroupsKey);
            }
            store.CreateCollection(projectGroupsKey);

            foreach (DocumentGroup group in groups)
            {
                var serializedGroup = JsonConvert.SerializeObject(group);
                store.SetString(projectGroupsKey, group.Name, serializedGroup);
            }
        }
示例#2
0
        //=====================================================================

        /// <summary>
        /// This is used to load the MEF provider configuration settings
        /// </summary>
        /// <returns>True if loaded successfully or false if the settings could not be loaded</returns>
        /// <remarks>The settings are loaded from Visual Studio user setting store</remarks>
        private bool LoadConfiguration()
        {
            bool success = false;

            try
            {
                var settingsManager = new ShellSettingsManager(serviceProvider);
                var settingsStore   = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

                if (settingsStore.CollectionExists(CollectionPath))
                {
                    EnableExtendedXmlCommentsCompletion = settingsStore.GetBoolean(CollectionPath,
                                                                                   "EnableExtendedXmlCommentsCompletion", true);
                    EnableGoToDefinition          = settingsStore.GetBoolean(CollectionPath, "EnableGoToDefinition", true);
                    EnableCtrlClickGoToDefinition = settingsStore.GetBoolean(CollectionPath,
                                                                             "EnableCtrlClickGoToDefinition", true);
                    EnableGoToDefinitionInCRef = settingsStore.GetBoolean(CollectionPath,
                                                                          "EnableGoToDefinitionInCRef", !IntelliSense.RoslynHacks.RoslynUtilities.IsFinalRoslyn);
                    success = true;
                }
            }
            catch (Exception ex)
            {
                // Ignore exceptions.  We'll just use the defaults.
                System.Diagnostics.Debug.WriteLine(ex);
            }

            return(success);
        }
示例#3
0
        static StaticBoilerplateSettings()
        {
            SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);

            Store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            Store.CreateCollection(CollectionPath);

            if (Store.PropertyExists(CollectionPath, TestProjectsKey))
            {
                string dictionaryString = Store.GetString(CollectionPath, TestProjectsKey);

                if (string.IsNullOrEmpty(dictionaryString))
                {
                    TestProjectsDictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                }
                else
                {
                    TestProjectsDictionary = new Dictionary <string, string>(JsonConvert.DeserializeObject <Dictionary <string, string> >(dictionaryString), StringComparer.OrdinalIgnoreCase);
                }
            }
            else
            {
                TestProjectsDictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            }
        }
        private void LoadSettings()
        {
            SettingsManager       settingsManager            = new ShellSettingsManager(this);
            WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            _settings = new Settings(configurationSettingsStore);
        }
示例#5
0
        public Settings(IServiceProvider provider)
        {
            SettingsManager settingsManager = new ShellSettingsManager(provider);

            _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses"))
            {
                return;
            }
            IEnumerable <string> services = _settingsStore.GetSubCollectionNames("DebugAttachManagerProcesses");

            foreach (var s in services)
            {
                var p = new StoredProcessInfo
                {
                    ProcessName = _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "ProcessName"),
                    Title       = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "Title") ?
                                  _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "Title") : null,
                    RemoteServerName = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemoteServerName") ?
                                       _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "RemoteServerName") : null,
                    RemotePortNumber = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") ?
                                       _settingsStore.GetInt64("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") : (long?)null,
                    Selected  = _settingsStore.GetBoolean("DebugAttachManagerProcesses\\" + s, "Selected"),
                    DebugMode = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "DebugMode") ?
                                _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "DebugMode") : null
                };
                Processes.Add(p.Hash, p);
            }

            if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", "RemoteServer"))
            {
                RemoteServer = _settingsStore.GetString("DebugAttachManagerProcesses", "RemoteServer");
            }
        }
示例#6
0
        /// <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>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken,
                                                      IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            var settingsManager       = new ShellSettingsManager(this);
            var writableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            var settingsStore         = new SettingsService(writableSettingsStore);

            var dte = (DTE) await GetServiceAsync(typeof(SDTE));

            var applicationEvents = dte.Application.Events;
            var documentEvents    = applicationEvents.DocumentEvents;
            var devEnvEvents      = dte.Events.DTEEvents;
            var enviromentEvents  = new WindowsEnvironmentService(this, documentEvents, applicationEvents.SolutionEvents,
                                                                  dte.Application.Solution, devEnvEvents);

            var dependencyContainer = new DependencyContainer(new DependenciesRegistrar());
            var guiPresenter        = new GuiService(this, dependencyContainer);

            await EnableExtensionCommand.InitializeAsync(this);

            await DisableExtensionCommand.InitializeAsync(this);

            var commandsDictionary = new Dictionary <HotReloadCommands, IEnvironmentCommand>
            {
                { HotReloadCommands.Enable, EnableExtensionCommand.Instance },
                { HotReloadCommands.Disable, DisableExtensionCommand.Instance }
            };

            Main.Init(enviromentEvents, commandsDictionary, guiPresenter, settingsStore);
        }
        private static WritableSettingsStore GetWritableSettingsStore(IServiceProvider serviceProvider)
        {
            var shellSettingsManager  = new ShellSettingsManager(serviceProvider);
            var writableSettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            return(writableSettingsStore);
        }
示例#8
0
        private List <DocumentGroup> LoadGroupsForSolution()
        {
            var solution = SolutionName;

            if (!string.IsNullOrWhiteSpace(solution))
            {
                try
                {
                    var settingsMgr = new ShellSettingsManager(ServiceProvider);
                    var store       = settingsMgr.GetReadOnlySettingsStore(SettingsScope.UserSettings);

                    var propertyName = String.Format(SavedTabsStoragePropertyFormat, solution);
                    if (store.PropertyExists(StorageCollectionPath, propertyName))
                    {
                        var tabs = store.GetString(StorageCollectionPath, propertyName);
                        return(JsonConvert.DeserializeObject <List <DocumentGroup> >(tabs));
                    }
                }
                catch (Exception ex)
                {
                    Debug.Assert(false, "LoadGroupsForSolution", ex.ToString());
                }
            }
            return(new List <DocumentGroup>());
        }
示例#9
0
        private void SaveGroupsForSolution(IList <DocumentGroup> groups = null)
        {
            var solution = SolutionName;

            if (string.IsNullOrWhiteSpace(solution))
            {
                return;
            }

            if (groups == null)
            {
                groups = Groups;
            }

            var settingsMgr = new ShellSettingsManager(ServiceProvider);
            var store       = settingsMgr.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!store.CollectionExists(StorageCollectionPath))
            {
                store.CreateCollection(StorageCollectionPath);
            }

            var propertyName = String.Format(SavedTabsStoragePropertyFormat, solution);

            if (!groups.Any())
            {
                store.DeleteProperty(StorageCollectionPath, propertyName);
                return;
            }

            var tabs = JsonConvert.SerializeObject(groups);

            store.SetString(StorageCollectionPath, propertyName, tabs);
        }
示例#10
0
        private static int?GetValueFromPrivateSettingsTextEditor(IServiceProvider serviceProvider, string languageName, string propertyName)
        {
            if (serviceProvider == null)
            {
                return(null);
            }
            if (string.IsNullOrWhiteSpace(languageName))
            {
                return(null);
            }

            SettingsManager settingsManager   = new ShellSettingsManager(serviceProvider);
            var             userSettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            var privateSettingsTextEditorLanguage = $@"ApplicationPrivateSettings\TextEditor\{languageName}";

            if (userSettingsStore.CollectionExists(privateSettingsTextEditorLanguage) &&
                userSettingsStore.PropertyExists(privateSettingsTextEditorLanguage, propertyName))
            {
                var value = userSettingsStore.GetString(privateSettingsTextEditorLanguage, propertyName);

                if (int.TryParse(value?.Split('*').Last(), out int buff))
                {
                    return(buff);
                }
            }
            return(null);
        }
        private WritableSettingsStore GetSettingsStore()
        {
            SettingsManager       settingsManager   = new ShellSettingsManager(ConfigCommand.ServiceProviderForWindow);
            WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            return(userSettingsStore);
        }
示例#12
0
        /// <summary>
        /// Saves the properties to the registry asyncronously.
        /// </summary>
        public virtual async Task SaveAsync()
        {
            ShellSettingsManager manager = await _settingsManager.GetValueAsync().ConfigureAwait(true);

            WritableSettingsStore settingsStore = manager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!settingsStore.CollectionExists(CollectionName))
            {
                settingsStore.CreateCollection(CollectionName);
            }

#if DEBUG_OPTION_VALUES_LOAD_SAVE
            Debug.WriteLine($"SaveAsync<{typeof(T).Name}>()");
#endif
            var propertiesToSerialize = GetOptionProperties();
            foreach (PropertyInfo property in propertiesToSerialize)
            {
                string output = SerializeValue(property.GetValue(this));
#if DEBUG_OPTION_VALUES_LOAD_SAVE
                Debug.WriteLine($"{property.Name} = {property.GetValue(this)}");
#endif
                settingsStore.SetString(CollectionName, property.Name, output);
            }
#if DEBUG_OPTION_VALUES_LOAD_SAVE
            Debug.WriteLine($"SaveAsync<{typeof(T).Name}>() finished =================================");
#endif
        }
示例#13
0
        void BeforeQueryStatus(object sender, EventArgs e)
        {
            var command = sender as OleMenuCommand;

            if (command == null)
            {
                return;
            }

            var settingsManager = new ShellSettingsManager(ServiceProvider);
            var store           = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            switch (command.CommandID.ID)
            {
            case OnlineDocumentationId:
                command.Checked = !store.GetBoolean(Statics.HelpPreferencePath,
                                                    Statics.HelpPreferenceKey, false);
                break;

            case OfflineDocumentationId:
                command.Checked = store.GetBoolean(Statics.HelpPreferencePath,
                                                   Statics.HelpPreferenceKey, true);
                break;
            }
        }
示例#14
0
        public SettingsRepository(IServiceProvider vsServiceProvider)
        {
            _vsServiceProvider = vsServiceProvider;
            var ssm = new ShellSettingsManager(_vsServiceProvider);

            _writableSettingsStore = ssm.GetWritableSettingsStore(SettingsScope.UserSettings);
        }
示例#15
0
        public FormsPlayerViewModel([Import(typeof(SVsServiceProvider))] IServiceProvider services)
        {
            ConnectCommand        = new DelegateCommand(Connect, () => !isConnected);
            DisconnectCommand     = new DelegateCommand(Disconnect, () => isConnected);
            events                = services.GetService <DTE>().Events.DocumentEvents;
            events.DocumentSaved += document => Publish(document.FullName);

            var manager = new ShellSettingsManager(services);

            settings = manager.GetWritableSettingsStore(SettingsScope.UserSettings);
            if (!settings.CollectionExists(SettingsPath))
            {
                settings.CreateCollection(SettingsPath);
            }
            if (settings.PropertyExists(SettingsPath, SettingsKey))
            {
                SessionId = settings.GetString(SettingsPath, SettingsKey, "");
            }

            if (string.IsNullOrEmpty(SessionId))
            {
                // Initialize SessionId from MAC address.
                var mac = NetworkInterface.GetAllNetworkInterfaces()
                          .Where(nic => nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
                          .Select(nic => nic.GetPhysicalAddress().ToString())
                          .First();

                SessionId = NaiveBijective.Encode(NaiveBijective.Decode(mac));
            }

            TaskScheduler.UnobservedTaskException += OnTaskException;
        }
示例#16
0
        private void RaiseParametersChanged(Parameter param)
        {
            if (ParametersChanged != null)
            {
                ParametersChanged(this, new ParametersEnventArgs(param));
            }

            if (param == Parameter.Port || param == Parameter.DisableESMTP)
            {
                SettingsManager       settingsManager            = new ShellSettingsManager(VMSTPSettingsStore.ServiceProvider);
                WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                bool collectionExists = configurationSettingsStore.CollectionExists(VMSTPSettingsStore.Collection);
                if (!collectionExists)
                {
                    configurationSettingsStore.CreateCollection(VMSTPSettingsStore.Collection);
                }

                if (collectionExists || configurationSettingsStore.CollectionExists(VMSTPSettingsStore.Collection))
                {
                    configurationSettingsStore.SetBoolean(VMSTPSettingsStore.Collection, "DisableESMTP", DisableESMTP);
                    configurationSettingsStore.SetInt32(VMSTPSettingsStore.Collection, "Port", Port);
                }
            }
        }
示例#17
0
        private async Task <Guid> GetCurrentThemeAsync(CancellationToken cancellationToken)
        {
            const string COLLECTION_NAME = @"ApplicationPrivateSettings\Microsoft\VisualStudio";
            const string PROPERTY_NAME   = "ColorTheme";

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            IVsSettingsManager manager = (IVsSettingsManager)await VS.Services.GetSettingsManagerAsync();

            SettingsStore store = new ShellSettingsManager(manager).GetReadOnlySettingsStore(SettingsScope.UserSettings);

            if (store.CollectionExists(COLLECTION_NAME))
            {
                if (store.PropertyExists(COLLECTION_NAME, PROPERTY_NAME))
                {
                    // The value is made up of three parts, separated
                    // by a star. The third part is the GUID of the theme.
                    string[] parts = store.GetString(COLLECTION_NAME, PROPERTY_NAME).Split('*');
                    if (parts.Length == 3)
                    {
                        if (Guid.TryParse(parts[2], out Guid value))
                        {
                            return(value);
                        }
                    }
                }
            }

            return(Guid.Empty);
        }
        void LoadSettings()
        {
            SettingsManager       settingsManager            = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider);
            WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            string adb_path  = configurationSettingsStore.GetString(StoreCategoryName, StorePropertyAdbPathName, "");
            uint   log_limit = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyLogsLimitName, 20000);
            bool   is_auto   = configurationSettingsStore.GetBoolean(StoreCategoryName, StorePropertyAutoScrollName, false);

            LogLimitCount  = log_limit;
            adb.AdbExePath = adb_path;
            IsAutoScroll   = is_auto;
            ColumnWidth[0] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyLevelWidthName, 60);
            ColumnWidth[1] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTimeWidthName, 120);
            ColumnWidth[2] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyPidWidthName, 60);
            ColumnWidth[3] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTagWidthName, 120);
            ColumnWidth[4] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTextWidthName, 600);

            if (IsAutoScroll)
            {
                Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll On"; });
            }
            else
            {
                Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll Off"; });
            }
        }
示例#19
0
        public void SaveSettings()
        {
            QtVSIPSettings.SaveMocDirectory(newMocDir);
            QtVSIPSettings.SaveMocOptions(newMocOptions);
            QtVSIPSettings.SaveUicDirectory(newUicDir);
            QtVSIPSettings.SaveRccDirectory(newRccDir);
            QtVSIPSettings.SaveLUpdateOnBuild(newLUpdateOnBuild);
            QtVSIPSettings.SaveLUpdateOptions(newLUpdateOptions);
            QtVSIPSettings.SaveLReleaseOptions(newLReleaseOptions);
            QtVSIPSettings.SaveAskBeforeCheckoutFile(newAskBeforeCheckoutFile);
            QtVSIPSettings.SaveDisableCheckoutFiles(newDisableCheckoutFiles);
            QtVSIPSettings.SaveDisableAutoMocStepsUpdate(newDisableAutoMOCStepsUpdate);

            var settingsManager = new ShellSettingsManager(Vsix.Instance);
            var store           = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

#if VS2013
            store.CreateCollection(Statics.QmlClassifierPath);
            store.SetBoolean(Statics.QmlClassifierPath, Statics.QmlClassifierKey,
                             EnableQmlClassifier);
#else
            store.CreateCollection(Statics.QmlTextMatePath);
            store.SetBoolean(Statics.QmlTextMatePath, Statics.QmlTextMateKey, EnableQmlTextMate);
#endif
        }
        public void LoadFilterStoreData()
        {
            SettingsManager       settingsManager = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider);
            WritableSettingsStore settingsStore   = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (settingsStore.CollectionExists(StoreFilterCollectionName))
            {
                int count = settingsStore.GetSubCollectionCount(StoreFilterCollectionName);
                IEnumerable <string> filter_name_list = settingsStore.GetSubCollectionNames(LogcatOutputToolWindowControl.StoreFilterCollectionName);
                if (filter_name_list == null)
                {
                    return;
                }
                foreach (string name in filter_name_list)
                {
                    string filter_sub_collection = StoreFilterCollectionName
                                                   + "\\" + name;
                    string tag = settingsStore.GetString(filter_sub_collection,
                                                         LogcatOutputToolWindowControl.StorePropertyFilterTagName, "");
                    int pid = settingsStore.GetInt32(filter_sub_collection,
                                                     LogcatOutputToolWindowControl.StorePropertyFilterPidName, 0);
                    string msg = settingsStore.GetString(filter_sub_collection,
                                                         LogcatOutputToolWindowControl.StorePropertyFilterMsgName, "");
                    string pkg = settingsStore.GetString(filter_sub_collection,
                                                         LogcatOutputToolWindowControl.StorePropertyFilterPackageName, "");
                    int level = settingsStore.GetInt32(filter_sub_collection,
                                                       LogcatOutputToolWindowControl.StorePropertyFilterLevelName, 0);
                    AddFilterItem(name, tag, pid, msg, pkg,
                                  (LogcatOutputToolWindowControl.LogcatItem.Level)level, false);
                }
            }
        }
示例#21
0
        public SettingStoreProvider(string collection)
        {
            this.collection = collection;
            SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);

            userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
        }
        private WritableSettingsStore GetSettings()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);

            return(settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings));
        }
示例#23
0
        public PackageSettings([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
        {
            var sm = new ShellSettingsManager(serviceProvider);

            settingsStore = new SettingsStore(sm.GetWritableSettingsStore(SettingsScope.UserSettings), Info.ApplicationInfo.ApplicationSafeName);
            LoadSettings();
        }
示例#24
0
        /// <summary>
        /// Saves the properties to the registry asyncronously.
        /// </summary>
        public virtual async Task SaveAsync()
        {
            ShellSettingsManager manager = await _settingsManager.GetValueAsync();

            WritableSettingsStore settingsStore = manager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!settingsStore.CollectionExists(CollectionName))
            {
                settingsStore.CreateCollection(CollectionName);
            }

            foreach (PropertyInfo property in GetOptionProperties())
            {
                var output = SerializeValue(property.GetValue(this));
                settingsStore.SetString(CollectionName, property.Name, output);
            }

            T liveModel = await GetLiveInstanceAsync();

            if (this != liveModel)
            {
                await liveModel.LoadAsync();
            }

            Saved?.Invoke(this, liveModel);
        }
示例#25
0
        /// <summary>
        /// Sets the verbosity level.
        /// </summary>
        private void SetVerbosity()
        {
            if (!this.haveCachedVerbosity)
            {
                this.Verbosity = LoggerVerbosity.Normal;

                try
                {
                    var settings = new ShellSettingsManager(serviceProvider);
                    var store    = settings.GetReadOnlySettingsStore(SettingsScope.UserSettings);
                    if (store.CollectionExists(GeneralCollection) && store.PropertyExists(GeneralCollection, BuildVerbosityProperty))
                    {
                        this.Verbosity = (LoggerVerbosity)store.GetInt32(GeneralCollection, BuildVerbosityProperty, (int)LoggerVerbosity.Normal);
                    }
                }
                catch (Exception ex)
                {
                    var message = string.Format(
                        "Unable to read verbosity option from the registry.{0}{1}",
                        Environment.NewLine,
                        ex.ToString()
                        );
                    this.QueueOutputText(MessageImportance.High, message);
                }

                this.haveCachedVerbosity = true;
            }
        }
示例#26
0
        /// <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
                }
            }
        }
示例#27
0
        /// <summary>
        /// This is used to save the MEF provider configuration settings
        /// </summary>
        /// <remarks>The settings are saved to the Visual Studio user settings store</remarks>
        public bool SaveConfiguration()
        {
            bool success = false;

            try
            {
                var settingsManager = new ShellSettingsManager(serviceProvider);
                var settingsStore   = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (!settingsStore.CollectionExists(CollectionPath))
                {
                    settingsStore.CreateCollection(CollectionPath);
                }

                settingsStore.SetBoolean(CollectionPath, "EnableExtendedXmlCommentsCompletion",
                                         EnableExtendedXmlCommentsCompletion);
                settingsStore.SetBoolean(CollectionPath, "EnableGoToDefinition", EnableGoToDefinition);
                settingsStore.SetBoolean(CollectionPath, "EnableCtrlClickGoToDefinition",
                                         EnableCtrlClickGoToDefinition);
                settingsStore.SetBoolean(CollectionPath, "EnableGoToDefinitionInCRef", EnableGoToDefinitionInCRef);
                success = true;
            }
            catch (Exception ex)
            {
                // Ignore exceptions
                System.Diagnostics.Debug.WriteLine(ex);
            }

            return(success);
        }
示例#28
0
        public Options(SVsServiceProvider vsServiceProvider)
        {
            var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);

            _writableSettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            LoadSettings();
        }
示例#29
0
        /// <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);
                }
            }
        }
示例#30
0
        private List <DocumentGroup> LoadGroupsFromSettingsStore(string solutionName)
        {
            var settingsMgr = new ShellSettingsManager(ServiceProvider);
            var store       = settingsMgr.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            var propertyName = String.Format(SavedTabsStoragePropertyFormat, solutionName);

            if (store.PropertyExists(StorageCollectionPath, propertyName))
            {
                var tabs = store.GetString(StorageCollectionPath, propertyName);
                return(JsonConvert.DeserializeObject <List <DocumentGroup> >(tabs));
            }
            else if (store.PropertyExists(StorageCollectionPath, $"{propertyName}.0"))
            {
                var n    = 0;
                var tabs = "";
                while (store.PropertyExists(StorageCollectionPath, $"{propertyName}.{n}"))
                {
                    tabs += store.GetString(StorageCollectionPath, $"{propertyName}.{n}");
                    n    += 1;
                }
                return(JsonConvert.DeserializeObject <List <DocumentGroup> >(tabs));
            }
            return(new List <DocumentGroup>());
        }