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>()); }
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>()); }
/// <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 } } }
/// <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; } }
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; } }
//===================================================================== /// <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); }
private static bool?GetOutOfProcessSettingFromSessionStore(AcuminatorVSPackage package) { const bool defaultOutOfProcessValue = true; const string settingsStoreOutOfProcessValuePath = @"Roslyn\Internal\OnOff\Features"; const string OutOfProcessPropertyName = "OOP64Bit"; var shellSettingsManager = new ShellSettingsManager(package); SettingsStore settingsStore = shellSettingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (settingsStore == null) { return(null); } else if (!settingsStore.CollectionExists(settingsStoreOutOfProcessValuePath)) { return(defaultOutOfProcessValue); } var propertyNames = settingsStore.GetPropertyNames(settingsStoreOutOfProcessValuePath); if (!propertyNames.Contains(OutOfProcessPropertyName)) { return(defaultOutOfProcessValue); } int?outOfProcessValue = settingsStore.GetInt32(settingsStoreOutOfProcessValuePath, OutOfProcessPropertyName) as int?; return(outOfProcessValue.HasValue ? outOfProcessValue == 1 : defaultOutOfProcessValue); }
// Must happen on the UI thread. private IEnumerable <IOmniBoxItemsSource> CreateSources() { var settingsManager = new ShellSettingsManager(this.shellServiceProvider); var settingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.Configuration); if (settingsStore.CollectionExists(QuickLaunchStoreName)) { foreach (var searchProviderId in settingsStore.GetSubCollectionNames(QuickLaunchStoreName)) { var collectionPath = $@"{QuickLaunchStoreName}\{searchProviderId}"; if (settingsStore.PropertyExists(collectionPath, PackageKeyName) && (settingsStore.GetPropertyType(collectionPath, PackageKeyName) == SettingsType.String)) { var packageId = settingsStore.GetString(collectionPath, PackageKeyName); if ((packageId != null) && Guid.TryParse(packageId, out var packageGuid) && Guid.TryParse(searchProviderId, out var searchProviderGuid)) { var searchProvider = VsShellUtilities .TryGetPackageExtensionPoint <IVsSearchProvider, IVsSearchProvider>(packageGuid, searchProviderGuid); if ((searchProvider != null) && (searchProvider.Category.ToString() != MREProviderCategory)) { yield return(new QuickLaunchItemsSource(searchProvider)); } } } } } }
private void CopyTextMateLanguageFiles() { #if (!VS2013) var settingsManager = new ShellSettingsManager(Vsix.Instance); var store = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); var qttmlanguage = Environment. ExpandEnvironmentVariables("%USERPROFILE%\\.vs\\Extensions\\qttmlanguage"); if (store.GetBoolean(Statics.QmlTextMatePath, Statics.QmlTextMateKey, true)) { HelperFunctions.CopyDirectory(Path.Combine(PkgInstallPath, "qttmlanguage"), qttmlanguage); } else { Directory.Delete(qttmlanguage, true); } //Remove textmate-based QML syntax highlighting var qmlTextmate = Path.Combine(qttmlanguage, "qml"); if (Directory.Exists(qmlTextmate)) { try { Directory.Delete(qmlTextmate, true); } catch { } } #endif }
private static void OnBeforeQueryStatus(OleMenuCommand menuItem) { SettingsStore store = _settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); menuItem.Checked = store.GetBoolean("Debugger", "JustMyCode", true); menuItem.Enabled = true; // Enable on package load }
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); }
/// <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); } }
private void Button1_Click(object sender, RoutedEventArgs e) { SettingsStore configurationStore = _settingsManager.GetReadOnlySettingsStore(SettingsScope.Configuration); var enumerator = new AutoLoadPackageEnumerator(configurationStore); var packageList = enumerator.GetAutoLoadPackages().ToList(); gridOutput.ItemsSource = packageList; }
/// <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 void GetTextMateLanguagePath() { var settingsManager = new ShellSettingsManager(this as System.IServiceProvider); var store = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); useQtTmLanguage = store.GetBoolean(@"QtVsTools\Qml\TextMate", @"Enable", true); qtTmLanguagePath = Environment. ExpandEnvironmentVariables("%USERPROFILE%\\.vs\\Extensions\\qttmlanguage"); }
private static bool GetRoundFontSizesSetting() { var globalServiceProvider = (IServiceProvider)Package.GetGlobalService(typeof(IServiceProvider)); using var provider = new ServiceProvider(globalServiceProvider); var settingsManager = new ShellSettingsManager(provider); var userSettings = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); return(userSettings.GetBoolean("Text Editor", "RoundFontSizes", true)); }
/// <summary> /// Gets the columns of the guide lines. /// </summary> public static IEnumerable <int> GetGuideColumns() { ThreadHelper.ThrowIfNotOnUIThread(); var settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); SettingsStore userSettings = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); return(GetGuideColumns(userSettings)); }
internal static async Task <SettingsStore> GetReadonlySettingsStoreAsync() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var serviceProvder = MainWindowCommand.Instance.ServiceProvider; var svc = await serviceProvder.GetServiceAsync(typeof(SVsSettingsManager)) as IVsSettingsManager; var settingsManager = new ShellSettingsManager(svc); return(settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings)); }
public DataPersistenceService(IServiceProvider VsPackage, IServiceProvider services) { var settingsManager = new ShellSettingsManager(VsPackage); _readOnlySettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); _writableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); var logSvc = services.GetRequiredService <ILoggingService>(); _logger = logSvc.Logger; }
public ServerParameters() { SettingsManager settingsManager = new ShellSettingsManager(VMSTPSettingsStore.ServiceProvider); SettingsStore configurationSettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (configurationSettingsStore.CollectionExists(VMSTPSettingsStore.Collection)) { disableESMTP = configurationSettingsStore.GetBoolean(VMSTPSettingsStore.Collection, "DisableESMTP", DisableESMTP); port = configurationSettingsStore.GetInt32(VMSTPSettingsStore.Collection, "Port", Port); } }
/// <summary> /// Initializes a new instance of the <see cref="HotSettingsCommandHandler"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> private HotSettingsCommandHandler(Package package) { this.package = package ?? throw new ArgumentNullException("package"); ShellSettingsManager settingsManager = new ShellSettingsManager(package); SettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); OptionsService = ServicesUtil.GetMefService <IEditorOptionsFactoryService>(this.ServiceProvider); RegisterGlobalCommands(); }
public SettingsStoreContainer GetSettingsStore(bool readOnly) { var serviceProvider = new ServiceProvider((IServiceProvider)_dte2); var settingsManager = new ShellSettingsManager(serviceProvider); var settingsStore = readOnly ? settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings) : settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); var container = new SettingsStoreContainer(serviceProvider, settingsStore); return(container); }
public void LoadSettings() { if (_provider != null) { var settingsManager = new ShellSettingsManager(_provider); var store = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); SplitCharacter = Convert.ToChar(store.GetUInt32(SettingsCollectionPath, SplitCharacterString, '.')); } else { SplitCharacter = '.'; } }
private byte[] GetTokenFromSettings() { var settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); var userSettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (!userSettingsStore.CollectionExists(_collectionPath)) { return(null); } var encryptedToken = userSettingsStore.GetMemoryStream(_collectionPath, "ApiKey").ToArray(); return(encryptedToken); }
/// <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 }
/// <summary> /// Initializes properties in the package /// </summary> /// <param name="package">The package</param> private void Initialize(ShelvesetComparerPackage package) { SettingsManager settingsManager = new ShellSettingsManager(package); this.writableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!this.writableSettingsStore.CollectionExists(CollectionPath)) { this.writableSettingsStore.CreateCollection(CollectionPath); this.ShowAsButton = true; this.TwoUsersView = true; } this.readableSettingStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); }
/// <summary> /// Find Visual Studio's list of binding paths. /// </summary> /// <returns>A list of binding paths.</returns> public static IEnumerable <string> FindBindingPaths(IServiceProvider serviceProvider) { const string bindingPaths = "BindingPaths"; var manager = new ShellSettingsManager(serviceProvider); var store = manager.GetReadOnlySettingsStore(SettingsScope.Configuration); foreach (var guid in store.GetSubCollectionNames(bindingPaths)) { var guidPath = Path.Combine(bindingPaths, guid); foreach (var path in store.GetPropertyNames(guidPath)) { yield return(path); } } }
//===================================================================== /// <summary> /// This is used to load the MEF provider configuration settings /// </summary> /// <returns>True if loaded successfully or false if the settings collection does not exist</returns> /// <remarks>The settings are loaded using the <see cref="ShellSettingsManager"/> from the /// <see cref="CollectionPath"/> collection.</remarks> private bool LoadConfiguration() { ShellSettingsManager settingsManager = new ShellSettingsManager(_serviceProvider); SettingsStore settingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (!settingsStore.CollectionExists(CollectionPath)) { return(false); } EnableExtendedXmlCommentsCompletion = settingsStore.GetBoolean(CollectionPath, "EnableExtendedXmlCommentsCompletion", true); EnableGoToDefinition = settingsStore.GetBoolean(CollectionPath, "EnableGoToDefinition", true); EnableGoToDefinitionInCRef = settingsStore.GetBoolean(CollectionPath, "EnableGoToDefinitionInCRef", DefaultEnableGoToDefinitionInCRef); return(true); }
private List <DocumentGroup> LoadGroupsForSolution() { ThreadHelper.ThrowIfNotOnUIThread(); var solution = SolutionName; List <DocumentGroup> groups = new List <DocumentGroup>(); if (string.IsNullOrWhiteSpace(solution)) { return(groups); } try { var settingsMgr = new ShellSettingsManager(ServiceProvider); var store = settingsMgr.GetReadOnlySettingsStore(SettingsScope.UserSettings); string projectKeyHash = GetHashString(solution); string projectGroupsKey = string.Format(ProjectGroupsKeyPlaceholder, projectKeyHash); if (!store.CollectionExists(projectGroupsKey)) { // try load tabs from older versions var propertyName = String.Format(SavedTabsStoragePropertyFormat, solution); if (store.PropertyExists(StorageCollectionPath, propertyName)) { var tabs = store.GetString(StorageCollectionPath, propertyName); groups = JsonConvert.DeserializeObject <List <DocumentGroup> >(tabs); } return(groups); } var groupProperties = store.GetPropertyNamesAndValues(projectGroupsKey); foreach (var groupProperty in groupProperties) { DocumentGroup group = JsonConvert.DeserializeObject <DocumentGroup>(groupProperty.Value.ToString()); groups.Add(group); } } catch (Exception ex) { Debug.Assert(false, nameof(LoadGroupsForSolution), ex.ToString()); } return(groups); }