public static bool IsTestAdapaterEnabled() { if (!checkedRegistryForTestAdapterEnabled) { using (var nodeKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(NodejsConstants.BaseRegistryKey)) using (var optionsKey = nodeKey.CreateSubKey("Options")) using (var categoryKey = optionsKey.CreateSubKey("testing")) { // If the value is set to something we disable this testadapter registryValueForTestAdapterEnabled = string.IsNullOrEmpty(categoryKey.GetValue("testadapter") as string); } checkedRegistryForTestAdapterEnabled = true; } return(registryValueForTestAdapterEnabled); }
private bool CheckKey(string editor, string extension) { var root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration); var reg = root.OpenSubKey("editors\\" + editor + "\\Extensions"); bool Ok = true; if (reg != null) { object value = reg.GetValue(extension); if (value is int && (int)value >= 0x42) { Ok = false; } reg.Close(); } return(Ok); }
private void TryRegisterAssembly() { try { RegistryKey regKey = Registry.ClassesRoot.OpenSubKey($@"CLSID\{{{AD7Guids.EngineGuid.ToString()}}}"); if (regKey != null) { return; // Already registered } string location = typeof(AD7Engine).Assembly.Location; string regasm = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe"; if (!Environment.Is64BitOperatingSystem) { regasm = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe"; } var regasmProcessStartInfo = new ProcessStartInfo(regasm, location); regasmProcessStartInfo.Verb = "runas"; regasmProcessStartInfo.RedirectStandardOutput = true; regasmProcessStartInfo.UseShellExecute = false; regasmProcessStartInfo.CreateNoWindow = true; Process process = Process.Start(regasmProcessStartInfo); while (!process.HasExited) { string txt = process.StandardOutput.ReadToEnd(); } using (RegistryKey config = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) { MonoRemoteDebuggerInstaller.RegisterDebugEngine(location, config); } } catch (UnauthorizedAccessException) { MessageBox.Show( "Failed finish installation of MonoRemoteDebugger - Please run Visual Studio once as Administrator...", "MonoRemoteDebugger", MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception ex) { logger.Error(ex); } }
bool ITextTemplatingEngineHost.LoadIncludeText(string requestFileName, out string content, out string location) { location = ((ITextTemplatingEngineHost)this).ResolvePath(requestFileName); if (File.Exists(location)) { content = File.ReadAllText(location); return(true); } using (var rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) using (var includeFoldersKey = rootKey.OpenSubKey(@"TextTemplating\IncludeFolders\.tt")) { foreach (var valueName in includeFoldersKey.GetValueNames()) { var includeFolder = includeFoldersKey.GetValue(valueName) as string; if (includeFolder == null) { continue; } location = Path.Combine(includeFolder, requestFileName); if (File.Exists(location)) { content = File.ReadAllText(location); // Our implementation doesn't require respecting the CleanupBehavior custom directive, and since // implementing a fallback custom directive processor would essencially force us to have two // different versions of the EF Power Tools (one for VS 2010, another one for VS 2012) the simplest // solution is to remove the custom directive from the in-memory copy of the ttinclude content = content.Replace(@"<#@ CleanupBehavior Processor=""T4VSHost"" CleanupAfterProcessingTemplate=""true"" #>", ""); return(true); } } } location = string.Empty; content = string.Empty; return(false); }
internal static bool ShouldUseV3CdpDebugger() { var userRegistryRoot = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: false); try { object userDebuggerOption = userRegistryRoot.OpenSubKey("Debugger")?.GetValue("EnableJavaScriptMultitargetNodeDebug"); if (userDebuggerOption is int optionVal) { return(optionVal != 0); } } catch (Exception) { } // do nothing. proceed to trying the feature flag below. var featureFlagsService = (IVsFeatureFlags)ServiceProvider.GlobalProvider.GetService(typeof(SVsFeatureFlags)); return(featureFlagsService is IVsFeatureFlags && featureFlagsService.IsFeatureEnabled("JavaScript.Debugger.V3CdpNodeDebugAdapter", false)); }
/// <summary> /// Called after Visual Studio services are available, before the frame is created (this.Frame can be null) /// </summary> protected override void Initialize() { ThreadHelper.ThrowIfNotOnUIThread(); this.package.Telemetry.TrackEvent(Constants.EventInitializePane); // Look up the value of WPF trace settings in the registry using (RegistryKey rootKey = VSRegistry.RegistryRoot(this, __VsLocalRegistryType.RegType_UserSettings, writable: true)) { this.dataBindingOutputLevelKey = rootKey.CreateSubKey(Constants.DataBindingTraceKey, writable: true); } this.HookDataBindingTraceLevel(); this.HookDebugEvents(); this.WaitForDebugOutputTextBuffer(); base.Initialize(); }
/// <summary> /// Reads a boolean value specifying whether to show or not show the dialog /// </summary> /// <param name="registryKey">The key containing the value.</param> /// <returns>The value read. If the value cannot be read false is returned.</returns> internal static bool ReadDontShowAgainValue(string registryKey) { bool dontShowAgain = false; using (RegistryKey root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings)) { if (root != null) { using (RegistryKey key = root.OpenSubKey(GeneralSubKey)) { int value = (int)key.GetValue(registryKey, 0); dontShowAgain = (value != 0); } } } return(dontShowAgain); }
protected System.Drawing.Color UpdateColorSetting(string name, System.Drawing.Color defaultColor) { using (var regKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings)) { if (regKey == null) { return(defaultColor); } using (var colorKey = regKey.OpenSubKey(PROP_LOCATION)) { if (colorKey == null) { return(defaultColor); } var prop = colorKey.GetValue(name) as string; if (prop == null) { return(defaultColor); } try { BlackSpaceColorConverter cc = new BlackSpaceColorConverter(); object Obj = cc.ConvertFromString(prop); if (Obj != null && Obj is System.Drawing.Color) { System.Drawing.Color color = (System.Drawing.Color)Obj; if (!color.IsEmpty) { return(color); } } } catch (Exception e) { System.Console.WriteLine(e.Message); return(defaultColor); } return(defaultColor); } } }
public static IEnumerable <ColumnState> LoadSettings(string window, IEnumerable <ColumnState> defaultColumns) { var columns = new List <Tuple <int, ColumnState> >(); using (var rootKey = VSRegistry.RegistryRoot(ProjectSystemToolsPackage.ServiceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: false)) { using (var columnsSubKey = rootKey.OpenSubKey(CreateColumnsKey(window), writable: false)) { if (columnsSubKey == null) { return(defaultColumns); } foreach (var columnName in columnsSubKey.GetSubKeyNames()) { using (var columnSubKey = columnsSubKey.OpenSubKey(columnName, writable: false)) { if (columnSubKey == null) { continue; } var descendingSort = (int)columnSubKey.GetValue(ColumnSortDown, 1) != 0; var sortPriority = (int)columnSubKey.GetValue(ColumnSortPriority, 0); var groupingPriority = (int)columnSubKey.GetValue(ColumnGroupingPriority, 0); var columnOrder = (int)columnSubKey.GetValue(ColumnOrder, int.MaxValue); var visibility = (int)columnSubKey.GetValue(ColumnVisibility, 0) != 0; var width = (int)columnSubKey.GetValue(ColumnWidth, 20); var state = new ColumnState2(columnName, visibility, width, sortPriority, descendingSort, groupingPriority); columns.Add(new Tuple <int, ColumnState>(columnOrder, state)); } } } } columns.Sort((a, b) => a.Item1 - b.Item1); return(columns.Select(a => a.Item2)); }
private void InitializeRegistrySettings() { using (var textEditor = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey("Text Editor")) { using (var ironRubyKey = textEditor.CreateSubKey(RubyConstants.TextEditorSettingsRegistryKey)) { object curValue; curValue = ironRubyKey.GetValue("Insert Tabs"); if (curValue == null) { ironRubyKey.SetValue("Insert Tabs", 0); } curValue = ironRubyKey.GetValue("Indent Size"); if (curValue == null) { ironRubyKey.SetValue("Indent Size", 2); } } } }
public void ApplyColorScheme(SchemeName schemeName, ImmutableArray <RegistryItem> registryItems) { using var registryRoot = VSRegistry.RegistryRoot(_serviceProvider, __VsLocalRegistryType.RegType_Configuration, writable: true); foreach (var item in registryItems) { using var itemKey = registryRoot.CreateSubKey(item.SectionName); itemKey.SetValue(item.ValueName, item.ValueData); // Flush RegistryKeys out of paranoia itemKey.Flush(); } registryRoot.Flush(); SetAppliedColorScheme(schemeName); // Broadcast that system color settings have changed to force the ColorThemeService to reload colors. NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, NativeMethods.WM_SYSCOLORCHANGE, wparam: IntPtr.Zero, lparam: IntPtr.Zero); }
/// <summary> /// Get the localized names of "Global", "Text Editor" and "Solution Explorer" scope. I wish there was a /// prettier way of doing this. However there is no API available which provides this information. We need to directly /// query some registry values here /// </summary> private static bool TryGetMainScopeNames(IVsShell vsShell, out string globalScopeName, out string textEditorScopeName, out string solutionExplorerScopeName) { globalScopeName = null; textEditorScopeName = null; solutionExplorerScopeName = null; try { using (var rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration, writable: false)) { using (var keyBindingsKey = rootKey.OpenSubKey("KeyBindingTables")) { // For "Global". The id in the registry here is incorrect for Vs 2010 // so hard code the known value if (!TryGetKeyBindingScopeName(vsShell, keyBindingsKey, "{5efc7975-14bc-11cf-9b2b-00aa00573819}", 13018, out globalScopeName)) { return(false); } // For "Text Editor". Many locals don't define this key so it's still considered a success // if we get only the global name. Just fill in the default here if (!TryGetKeyBindingScopeName(vsShell, keyBindingsKey, "{8B382828-6202-11D1-8870-0000F87579D2}", null, out textEditorScopeName)) { textEditorScopeName = DefaultTextEditorScopeName; } // The "Solution Explorer" scope is only relevant starting in VS2013. By default it contains a lot of // key bindings for '['. If we can't find the real name just use the default. We don't want its abscence // to screw up other scopes if (!TryGetKeyBindingScopeName(vsShell, keyBindingsKey, "{3AE79031-E1BC-11D0-8F78-00A0C9110057}", null, out solutionExplorerScopeName)) { solutionExplorerScopeName = DefaultSolutionExplorerScopeName; } } } return(true); } catch (Exception) { return(false); } }
public static bool SaveSettings(string window, IWpfTableControl control) { var columns = control.ColumnStates; using (var rootKey = VSRegistry.RegistryRoot(ProjectSystemToolsPackage.ServiceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true)) { using (var columnsSubKey = rootKey.CreateSubKey(CreateColumnsKey(window))) { if (columnsSubKey == null) { return(false); } for (var i = 0; i < columns.Count; i++) { var column = columns[i]; using (var columnSubKey = columnsSubKey.CreateSubKey(column.Name)) { if (columnSubKey == null) { continue; } columnSubKey.SetValue(ColumnOrder, i, RegistryValueKind.DWord); columnSubKey.SetValue(ColumnVisibility, column.IsVisible ? 1 : 0, RegistryValueKind.DWord); columnSubKey.SetValue(ColumnWidth, (int)column.Width, RegistryValueKind.DWord); columnSubKey.SetValue(ColumnSortDown, column.DescendingSort ? 1 : 0, RegistryValueKind.DWord); columnSubKey.SetValue(ColumnSortPriority, column.SortPriority, RegistryValueKind.DWord); if (column is ColumnState2 cs2) { columnSubKey.SetValue(ColumnGroupingPriority, cs2.GroupingPriority, RegistryValueKind.DWord); } } } } } return(true); }
internal static string LoadString(string name, string cat) { using (var pythonKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(VSGeneroConstants.BaseRegistryKey)) { if (pythonKey == null) { return(null); } using (var optionsKey = pythonKey.CreateSubKey(_optionsKey)) { if (optionsKey == null) { return(null); } using (var categoryKey = optionsKey.CreateSubKey(cat)) { return(categoryKey?.GetValue(name) as string); } } } }
private string LoadStringInternal(string name, string cat) { using (var regKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(_baseKey)) { if (regKey == null) { return(null); } using (var optionsKey = regKey.CreateSubKey(_optionsKey)) { if (optionsKey == null) { return(null); } using (var categoryKey = optionsKey.CreateSubKey(cat)) { return(categoryKey?.GetValue(name) as string); } } } }
internal static bool ShouldUseV3CdpDebugger() { var userRegistryRoot = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: false); try { object userDebuggerOption = userRegistryRoot.OpenSubKey("Debugger")?.GetValue("EnableJavaScriptMultitargetDebugging"); if (userDebuggerOption == null) { return(false); } else { return((int)userDebuggerOption != 0); } } catch (Exception) { return(false); } }
private static string LoadString(string name) { using (var pythonKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(VSGeneroConstants.BaseRegistryKey)) { if (pythonKey == null) { return(null); } using (var refactorKey = pythonKey.CreateSubKey(RefactorKey)) { if (refactorKey == null) { return(null); } using (var renameKey = refactorKey.CreateSubKey(RenameKey)) { return(renameKey?.GetValue(name) as string); } } } }
public static void TryRegisterAssembly() { // TODO move to AdapterRegistration.pkgdef // see https://github.com/microsoft/VSDebugAdapterHost/blob/master/src/sample/SampleDebugAdapter.VSIX/AdapterRegistration.pkgdef // see https://github.com/Microsoft/VSDebugAdapterHost/wiki // see https://github.com/microsoft/VSDebugAdapterHost/wiki/Packaging-a-VS-Code-Debug-Adapter-For-Use-in-VS RegistryKey regKey = Registry.ClassesRoot.OpenSubKey($@"CLSID\{{{DebugEngineGuids.EngineGuid.ToString()}}}"); if (regKey != null) { return; // Already registered } string location = typeof(XamarinEngine).Assembly.Location; string regasm = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe"; if (!Environment.Is64BitOperatingSystem) { regasm = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe"; } var regasmProcessStartInfo = new ProcessStartInfo(regasm, location); regasmProcessStartInfo.Verb = "runas"; regasmProcessStartInfo.RedirectStandardOutput = true; regasmProcessStartInfo.UseShellExecute = false; regasmProcessStartInfo.CreateNoWindow = true; System.Diagnostics.Process process = System.Diagnostics.Process.Start(regasmProcessStartInfo); while (!process.HasExited) { string txt = process.StandardOutput.ReadToEnd(); } using (RegistryKey config = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) { RegisterDebugEngine(location, config); } }
static GCManager() { // Allow disabling SustainedLowLatency by setting the reg key value to 0 System.Threading.Tasks.Task.Run(() => { using (var root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings)) { if (root != null) { using var key = root.OpenSubKey("Performance"); const string name = "SustainedLowLatencyDuration"; if (key != null && key.GetValue(name) != null && key.GetValueKind(name) == Microsoft.Win32.RegistryValueKind.DWord) { s_delayMilliseconds = (int)key.GetValue(name, s_delayMilliseconds); return; } } } s_delayMilliseconds = DefaultDelayMilliseconds; }); }
private void InitializeDefaultInterpreterWatcher(IServiceProvider serviceProvider) { RegistryKey userSettingsKey; if (serviceProvider != null) { userSettingsKey = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_UserSettings, false); } else { userSettingsKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, false); } using (userSettingsKey) { RegistryHive hive; RegistryView view; string keyName; if (RegistryWatcher.GetRegistryKeyLocation(userSettingsKey, out hive, out view, out keyName)) { if (RegistryWatcher.Instance.TryAdd( hive, view, keyName + "\\" + DefaultInterpreterOptionsCollection, DefaultInterpreterRegistry_Changed, recursive: false, notifyValueChange: true, notifyKeyChange: false ) == null) { // DefaultInterpreterOptions subkey does not exist yet, so // create it and then start the watcher. SaveDefaultInterpreter(); RegistryWatcher.Instance.Add( hive, view, keyName + "\\" + DefaultInterpreterOptionsCollection, DefaultInterpreterRegistry_Changed, recursive: false, notifyValueChange: true, notifyKeyChange: false ); } } } }
/// <summary> /// Get the localized names of the scopes who's key bindings we find interesting. This is /// a fairly unpretty way of doing this. Yet it's the only known way to achieve this in /// Dev10. /// </summary> private HashSet <string> CreateImportantScopeSet() { try { using (var rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration, writable: false)) { using (var keyBindingsKey = rootKey.OpenSubKey("KeyBindingTables")) { var set = new HashSet <string>(StringComparer.OrdinalIgnoreCase); // For "Global". The id in the registry here is incorrect for Dev10 // so hard code the known value set.Add(GetKeyBindingScopeName( keyBindingsKey, "{5efc7975-14bc-11cf-9b2b-00aa00573819}", 13018, "Global")); // For "Text Editor" set.Add(GetKeyBindingScopeName( keyBindingsKey, "{8B382828-6202-11D1-8870-0000F87579D2}", null, "Text Editor")); // No scope is considered interesting as well set.Add(""); return(set); } } } catch (Exception) { return(CreateDefaultImportantScopeSet()); } }
/// <summary> /// Gets the urls from registry. /// </summary> /// <returns></returns> private List <string> GetUrlsFromRegistry() { string empty = string.Empty; List <string> strs = new List <string>(); RegistryKey registryKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, false); using (registryKey) { if (registryKey != null) { RegistryKey registryKey1 = registryKey.OpenSubKey("SharePointTools", false); using (registryKey1) { if (registryKey1 != null) { for (int i = 1; i <= 10; i++) { object[] objArray = new object[1]; objArray[0] = i; string str = string.Format(CultureInfo.InvariantCulture, "SpUrl{0}", objArray); string value = registryKey1.GetValue(str, empty) as string; if (value != null && !(value == empty) && WizardHelpers.IsValidUriString(value, UriKind.Absolute)) { strs.Add(value); } } } } } } if (strs.Count == 0) { strs.Add(MRUHelper.GetLocalHostUrl()); } return(strs); }
protected virtual RegistryKey GetSettingsRootKey() { return(VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: true)); }
private void LoadSettings() { // Default values var lightTheme = WhereAmISettings.LightThemeDefaults(); FilenameSize = lightTheme.FilenameSize; FoldersSize = ProjectSize = lightTheme.FoldersSize; FilenameColor = lightTheme.FilenameColor; FoldersColor = ProjectColor = lightTheme.FoldersColor; Position = lightTheme.Position; Opacity = lightTheme.Opacity; ViewFilename = ViewFolders = ViewProject = lightTheme.ViewFilename; Theme = lightTheme.Theme; try { // Retrieve the Id of the current theme used in VS from user's settings, this is changed a lot in VS2015 string visualStudioThemeId = VSRegistry.RegistryRoot(Microsoft.VisualStudio.Shell.Interop.__VsLocalRegistryType.RegType_UserSettings).OpenSubKey("ApplicationPrivateSettings").OpenSubKey("Microsoft").OpenSubKey("VisualStudio").GetValue("ColorTheme", "de3dbbcd-f642-433c-8353-8f1df4370aba", Microsoft.Win32.RegistryValueOptions.DoNotExpandEnvironmentNames).ToString(); string parsedThemeId = ""; if (visualStudioThemeId.Contains("*")) { parsedThemeId = Guid.Parse(visualStudioThemeId.Split('*')[2]).ToString(); } else { parsedThemeId = Guid.Parse(visualStudioThemeId).ToString(); } switch (parsedThemeId) { case Constants.VisualStudioLightThemeId: // Light case Constants.VisualStudioBlueThemeId: // Blue default: // Just use the defaults break; case Constants.VisualStudioDarkThemeId: // Dark var darkTheme = WhereAmISettings.DarkThemeDefaults(); FilenameSize = darkTheme.FilenameSize; FoldersSize = ProjectSize = darkTheme.FoldersSize; FilenameColor = darkTheme.FilenameColor; FoldersColor = ProjectColor = darkTheme.FoldersColor; Position = darkTheme.Position; Opacity = darkTheme.Opacity; ViewFilename = ViewFolders = ViewProject = darkTheme.ViewFilename; Theme = darkTheme.Theme; break; } // Tries to retrieve the configurations if previously saved if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FilenameColor")) { this.FilenameColor = Color.FromArgb(writableSettingsStore.GetInt32(Constants.SettingsCollectionPath, "FilenameColor", this.FilenameColor.ToArgb())); } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FoldersColor")) { this.FoldersColor = Color.FromArgb(writableSettingsStore.GetInt32(Constants.SettingsCollectionPath, "FoldersColor", this.FoldersColor.ToArgb())); } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ProjectColor")) { this.ProjectColor = Color.FromArgb(writableSettingsStore.GetInt32(Constants.SettingsCollectionPath, "ProjectColor", this.ProjectColor.ToArgb())); } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ViewFilename")) { bool b = this.ViewFilename; if (Boolean.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ViewFilename"), out b)) { this.ViewFilename = b; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ViewFolders")) { bool b = this.ViewFolders; if (Boolean.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ViewFolders"), out b)) { this.ViewFolders = b; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ViewProject")) { bool b = this.ViewProject; if (Boolean.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ViewProject"), out b)) { this.ViewProject = b; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FilenameSize")) { double d = this.FilenameSize; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "FilenameSize"), out d)) { this.FilenameSize = d; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FoldersSize")) { double d = this.FoldersSize; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "FoldersSize"), out d)) { this.FoldersSize = d; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ProjectSize")) { double d = this.ProjectSize; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ProjectSize"), out d)) { this.ProjectSize = d; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "Position")) { AdornmentPositions p = this.Position; if (Enum.TryParse <AdornmentPositions>(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "Position"), out p)) { this.Position = p; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "Opacity")) { double d = this.Opacity; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "Opacity"), out d)) { this.Opacity = d; } } } catch (Exception ex) { Debug.Fail(ex.Message); } }
public LocalUserRegistryOptionPersister([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider) { // Starting in Dev16, the ILocalRegistry service behind this call is free-threaded, and since the service is offered by msenv.dll can be requested // without any marshalling (explicit or otherwise) to the UI thread. this._registryKey = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true); }
public LocalUserRegistryOptionPersister([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider) : base(assertIsForeground: true) // The VSRegistry.RegistryRoot call requires being on the UI thread or else it will marshal and risk deadlock { this._registryKey = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true); }
private static RegistryKey GetRegistryRoot() { return(VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: true).CreateSubKey(ActiveReplsKey)); }
public static void SaveSwitch(string window, string name, bool value) { using var rootKey = VSRegistry.RegistryRoot(ProjectSystemToolsPackage.ServiceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true); using var settingsSubKey = rootKey.CreateSubKey(CreateSettingsKey(window)); settingsSubKey?.SetValue(name, value ? 1 : 0); }
public static void LoadSwitch(string window, string name, bool defaultValue, out bool value) { using var rootKey = VSRegistry.RegistryRoot(ProjectSystemToolsPackage.ServiceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: false); using var settingsSubKey = rootKey.OpenSubKey(CreateSettingsKey(window), writable: false); value = settingsSubKey == null ? defaultValue : (int)settingsSubKey.GetValue(name, 0) != 0; }
public AbstractSettingStoreOptionSerializer(IServiceProvider serviceProvider) : base(assertIsForeground: true) // The VSRegistry.RegistryRoot call requires being on the UI thread or else it will marshal and risk deadlock { this.RegistryKey = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true); }