private static void SetOption(WritableSettingsStore store, string catelogName, string optionName, Color value) { if (!store.CollectionExists(COLLECTION_PATH)) { store.CreateCollection(COLLECTION_PATH); } store?.SetString(COLLECTION_PATH, CombineCatelogAndOptionName(catelogName, optionName), string.Join(",", value.R, value.G, value.B)); }
public void Save(UserSettings settings) { string json = JsonConvert.SerializeObject(settings); if (!store.CollectionExists("MonoRemoteDebugger")) { store.CreateCollection("MonoRemoteDebugger"); } store.SetString("MonoRemoteDebugger", "Settings", json); }
public void SetFormat(string registryKey, string format) { try { settings.SetString(RegistryPath + registryKey, "Format", format); } catch { settings.CreateCollection(RegistryPath + registryKey); } }
private static void CreateEntryForTestFramework(string oldTemplate, TemplateType templateType, TestFramework testFramework, MockFramework mockFramework) { string newTemplate; // If it's a File template, we need to replace some framework-based placeholders for test attributes. if (templateType == TemplateType.File) { newTemplate = StringUtilities.ReplaceTokens( oldTemplate, (tokenName, propertyIndex, builder) => { switch (tokenName) { case "TestClassAttribute": builder.Append(testFramework.TestClassAttribute); break; case "TestInitializeAttribute": builder.Append(testFramework.TestInitializeAttribute); break; case "TestCleanupAttribute": builder.Append(testFramework.TestCleanupAttribute); break; case "TestMethodAttribute": builder.Append(testFramework.TestMethodAttribute); break; default: // Pass through all other tokens. builder.Append($"${tokenName}$"); break; } }); } else { newTemplate = oldTemplate; } Store.SetString(CollectionPath, GetTemplateSettingsKey(testFramework, mockFramework, templateType), newTemplate); }
public void SaveUserSettings(UserSettingsModel userSettings) { SettingsManager settingsManager = new ShellSettingsManager(this); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); ReferencesResolverExtensionPackage.EnsureSettingsStoreCollectionExists(userSettingsStore); string settingsJson = ConvertUserSettingToJson(userSettings); userSettingsStore.SetString(PathCollectionString, UserSettingsProperty, settingsJson); }
public void SaveString(string name, string category, string value) { var path = GetCollectionPath(category); if (!_settingsStore.CollectionExists(path)) { _settingsStore.CreateCollection(path); } _settingsStore.SetString(path, name, value); }
public void Save(UserSettingsContainer settings) { var json = settings.SerializeToJson(); if (!_settingsStore.CollectionExists(SETTINGS_STORE_NAME)) { _settingsStore.CreateCollection(SETTINGS_STORE_NAME); } _settingsStore.SetString(SETTINGS_STORE_NAME, "Settings", json); }
protected void WriteStrings(string settingsRoot, string[] properties, string[] values) { Debug.Assert(properties.Length == values.Length); WritableSettingsStore userSettingsStore = GetWritableSettingsStore(settingsRoot); for (int i = 0; i < properties.Length; i++) { userSettingsStore.SetString(settingsRoot, properties[i], values[i]); } }
/// <summary> /// Updates the value of the specified property to the given guid value while setting its data type to System.Guid /// </summary> /// <param name="store">Extending class</param> /// <param name="collectionPath">Path of the collection of the property</param> /// <param name="propertyName">Name of the property</param> /// <param name="value">Value of the property</param> public static void SetGuid(this WritableSettingsStore store, string collectionPath, string propertyName, Guid?value) { if (value == null) { store.DeletePropertyIfExists(collectionPath, propertyName); } else { store.SetString(collectionPath, propertyName, value.ToString()); } }
/// <summary> /// Saves to store. /// </summary> /// <param name="store">The store.</param> /// <param name="entry">The entry.</param> /// <param name="value">The value.</param> /// <param name="converter">The converter.</param> private static void SaveToStore(WritableSettingsStore store, string entry, object value, TypeConverter converter) { ArgumentGuard.ArgumentNotNull(store, "store"); ArgumentGuard.ArgumentNotNullOrEmpty(entry, "entry"); ArgumentGuard.ArgumentNotNull(value, "value"); ArgumentGuard.ArgumentNotNull(converter, "converter"); store.SetString(CollectionName, entry, converter.ConvertTo(value, typeof(string)) as string); }
public static void SetString(string option, string value) { Initialize(); defaults[option] = value; if (persistent_settings == null) { return; } IEnumerable <string> collection = persistent_settings.GetSubCollectionNames("AntlrVSIX"); persistent_settings.SetString("AntlrVSIX", option, value); }
private static void EnsureSettingsStore(WritableSettingsStore settingsStore) { if (!settingsStore.CollectionExists(SettingsCollection)) { settingsStore.CreateCollection(SettingsCollection); } if (!settingsStore.PropertyExists(SettingsCollection, ToolchainProperty)) { settingsStore.SetString(SettingsCollection, ToolchainProperty, ToolchainDefault); } }
public static void SaveCurrent() { try { if (!settingsStore.CollectionExists(COLLECTION_PATH)) { settingsStore.CreateCollection(COLLECTION_PATH); } settingsStore.SetString(COLLECTION_PATH, nameof(FontSettings.Font), CurrentSettings.Font); settingsStore.SetString(COLLECTION_PATH, nameof(FontSettings.Size), CurrentSettings.Size.ToString(CultureInfo.InvariantCulture)); settingsStore.SetBoolean(COLLECTION_PATH, nameof(FontSettings.Italic), CurrentSettings.Italic); settingsStore.SetString(COLLECTION_PATH, nameof(FontSettings.Opacity), CurrentSettings.Opacity.ToString(CultureInfo.InvariantCulture)); SettingsSaved?.Invoke(null, EventArgs.Empty); } catch (Exception ex) { Debug.Fail(ex.Message); } }
private void OK_OnClick(object sender, RoutedEventArgs e) { SettingsManager settingsManager = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider); WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); configurationSettingsStore.CreateCollection(LogcatOutputToolWindowControl.StoreCategoryName); if (AdbPathText.Text.Length == 0) { configurationSettingsStore.DeleteProperty(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyAdbPathName); } else { configurationSettingsStore.SetString(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyAdbPathName, AdbPathText.Text); } uint log_limit = System.Convert.ToUInt32(LogLimitText.Text); configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyLogsLimitName, log_limit); ToolCtrl.LogLimitCount = log_limit; ToolCtrl.adb.AdbExePath = AdbPathText.Text; uint level_width = Convert.ToUInt32(LevelWidthText.Text); configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyLevelWidthName, level_width); uint time_width = Convert.ToUInt32(TimeWidthText.Text); configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyTimeWidthName, time_width); uint pid_width = Convert.ToUInt32(PIDWidthText.Text); configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyPidWidthName, pid_width); uint tag_width = Convert.ToUInt32(TagWidthText.Text); configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyTagWidthName, tag_width); uint text_width = Convert.ToUInt32(TextWidthText.Text); configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName, LogcatOutputToolWindowControl.StorePropertyTextWidthName, text_width); ToolCtrl.ColumnWidth[0] = level_width; ToolCtrl.ColumnWidth[1] = time_width; ToolCtrl.ColumnWidth[2] = pid_width; ToolCtrl.ColumnWidth[3] = tag_width; ToolCtrl.ColumnWidth[4] = text_width; ToolCtrl.RefreshColumnsWidth(); ToClose?.Invoke(); }
private void SaveSettings() { if (!_settingsStore.CollectionExists(settingsCategoryName)) { _settingsStore.CreateCollection(settingsCategoryName); } var legacySerializer = new LegacyConfigurationSerializer <ControlSettings>(); var value = legacySerializer.Serialize(Settings); _settingsStore.SetString(settingsCategoryName, settingsPropertyName, value); }
internal void SetString(string propertyName, string value) { EnsureCollectionExists(); try { _settingsStore.SetString(CollectionPath, propertyName, value); } catch (Exception e) { Report(String.Format(ErrorSetFormat, propertyName), e); } }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void MenuItemCallback(object sender, EventArgs e) { // Show a Message Box to prove we were here IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; DeployConfiguration config = new DeployConfiguration(); SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!userSettingsStore.CollectionExists("SyncIIS")) { userSettingsStore.CreateCollection("SyncIIS"); } config.Domain = userSettingsStore.GetString("SyncIIS", "Domain", ""); config.SetSecurePassword(userSettingsStore.GetString("SyncIIS", "Password", "")); config.Site = userSettingsStore.GetString("SyncIIS", "Site", ""); config.Source = userSettingsStore.GetString("SyncIIS", "Source", ""); config.Target = userSettingsStore.GetString("SyncIIS", "Target", "").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList <string>(); config.Username = userSettingsStore.GetString("SyncIIS", "Username", ""); SyncWindow window = new SyncWindow(config); window.ShowDialog(); var settings = window.Configuration; userSettingsStore.SetString("SyncIIS", "Domain", settings.Domain); userSettingsStore.SetString("SyncIIS", "Password", settings.GetUnsecurePassword()); userSettingsStore.SetString("SyncIIS", "Site", settings.Site); userSettingsStore.SetString("SyncIIS", "Source", settings.Source); userSettingsStore.SetString("SyncIIS", "Target", string.Join(",", settings.Target.ToArray())); userSettingsStore.SetString("SyncIIS", "Username", settings.Username); }
private void SaveSettings() { if (SettingsStore.CollectionExists(RecentCommandLinesCollectionName)) { SettingsStore.DeleteCollection(RecentCommandLinesCollectionName); } SettingsStore.CreateCollection(RecentCommandLinesCollectionName); for (int i = 0; i < RecentCommandLines.Count; i++) { SettingsStore.SetString(RecentCommandLinesCollectionName, i.ToString(), RecentCommandLines[i]); } }
private void UpdateConfigurationSettingsStore(ReportGeneratorOptions reportGeneratorOptions) { if (!_userSettingsStore.CollectionExists(ProjectSettings.CollectionName)) { _userSettingsStore.CreateCollection(ProjectSettings.CollectionName); } _userSettingsStore.SetString( ProjectSettings.CollectionName, ProjectSettings.ReportGenerationOptionsDataKey, JsonConvert.SerializeObject(reportGeneratorOptions) ); }
/// <remarks> /// Settings are stored under "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\[12.0Exp]\BuildVision\". /// </remarks> private static void SaveSettings(ControlSettings settings, IServiceProvider serviceProvider) { WritableSettingsStore store = GetWritableSettingsStore(serviceProvider); if (!store.CollectionExists(SettingsCategoryName)) { store.CreateCollection(SettingsCategoryName); } string value = settings.Serialize(); store.SetString(SettingsCategoryName, SettingsPropertyName, value); }
public void Save() { int i = 1; if (_settingsStore.CollectionExists("DebugAttachManagerProcesses")) { _settingsStore.DeleteCollection("DebugAttachManagerProcesses"); } foreach (var p in Processes.Values) { _settingsStore.CreateCollection("DebugAttachManagerProcesses\\Process " + i); if (p.Title != null) { _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "Title", p.Title); } if (p.RemoteServerName != null) { _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "RemoteServerName", p.RemoteServerName); } if (p.RemotePortNumber.HasValue) { _settingsStore.SetInt64("DebugAttachManagerProcesses\\Process " + i, "RemotePortNumber", p.RemotePortNumber.Value); } _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "ProcessName", p.ProcessName); _settingsStore.SetBoolean("DebugAttachManagerProcesses\\Process " + i, "Selected", p.Selected); if (p.DebugMode != null) { _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "DebugMode", p.DebugMode); } i++; } if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses")) { _settingsStore.CreateCollection("DebugAttachManagerProcesses"); } if (!string.IsNullOrEmpty(RemoteServer)) { _settingsStore.SetString("DebugAttachManagerProcesses", "RemoteServer", RemoteServer); } if (!string.IsNullOrEmpty(RemotePort)) { _settingsStore.SetString("DebugAttachManagerProcesses", "RemotePort", RemotePort); } if (!string.IsNullOrEmpty(RemoteUserName)) { _settingsStore.SetString("DebugAttachManagerProcesses", "RemoteUserName", RemoteUserName); } for (i = 0; i < Constants.NUMBER_OF_OPTIONAL_COLUMNS; i++) { string columnName = $"Column{i}"; _settingsStore.SetBoolean("DebugAttachManagerProcesses", columnName, _processesColumns[i]); } }
public void CreateFilterStoreData(string name, string tag, int pid, string text, string package, LogcatItem.Level level) { SettingsManager settingsManager = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider); WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); configurationSettingsStore.CreateCollection(LogcatOutputToolWindowControl.StoreFilterCollectionName); string filter_sub_collection = LogcatOutputToolWindowControl.StoreFilterCollectionName + "\\" + name; configurationSettingsStore.CreateCollection(filter_sub_collection); configurationSettingsStore.SetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterTagName, tag); configurationSettingsStore.SetInt32(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterPidName, pid); configurationSettingsStore.SetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterMsgName, text); configurationSettingsStore.SetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterPackageName, package); configurationSettingsStore.SetInt32(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterLevelName, (int)level); }
public static void SaveDirectorySettings(string directoryPath) { SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!userSettingsStore.CollectionExists("XamlToolkit")) { userSettingsStore.CreateCollection("XamlToolkit"); } userSettingsStore.SetString("XamlToolkit", "Directory", directoryPath); }
private void UpdateSettings() { string configVersion = null; if (_settingsStore.PropertyExists(CollectionPath, SettingsVersionPropertyName)) { configVersion = _settingsStore.GetString(CollectionPath, SettingsVersionPropertyName); } if (configVersion == null) { try { var connections = new List <ConnectionDetail>(); var deprecatedConnectionsXml = _settingsStore.GetString(CollectionPath, ConnectionsPropertyName); var deprecatedConnections = (List <McTools.Xrm.Connection.Deprecated.ConnectionDetail>)XmlSerializerHelper.Deserialize(deprecatedConnectionsXml, typeof(List <McTools.Xrm.Connection.Deprecated.ConnectionDetail>)); foreach (var connection in deprecatedConnections) { connections.Add(UpdateConnection(connection)); } var connectionsXml = XmlSerializerHelper.Serialize(connections); _settingsStore.SetString(CollectionPath, ConnectionsPropertyName, connectionsXml); _settingsStore.SetString(CollectionPath, SettingsVersionPropertyName, CurrentConfigurationVersion); } catch (Exception) { try { GetCrmConnections(); ConfigurationVersion = CurrentConfigurationVersion; _settingsStore.SetString(CollectionPath, SettingsVersionPropertyName, ConfigurationVersion); } catch (Exception ex2) { Logger.Write("Failed to convert connections: " + ex2.Message); } } } }
/// <remarks> /// Settings are stored under "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\[12.0Exp]\BuildVision\". /// </remarks> private static void SaveSettings(ControlSettings settings, IServiceProvider serviceProvider) { WritableSettingsStore store = GetWritableSettingsStore(serviceProvider); if (!store.CollectionExists(SettingsCategoryName)) { store.CreateCollection(SettingsCategoryName); } var legacySerializer = new LegacyConfigurationSerializer <ControlSettings>(); string value = legacySerializer.Serialize(settings); store.SetString(SettingsCategoryName, SettingsPropertyName, value); }
public static void Initialize(IServiceProvider provider) { _manager = new ShellSettingsManager(provider); _readStore = _manager.GetReadOnlySettingsStore(SettingsScope.UserSettings); _writeStore = _manager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!_writeStore.CollectionExists(_name)) { _writeStore.CreateCollection(_name); string defaults = string.Join(_separator, PreEnabledExtensions.List); _writeStore.SetString(_name, _identifierKey, defaults); } }
public static void Initialize(IServiceProvider provider) { _manager = new ShellSettingsManager(provider); _readStore = _manager.GetReadOnlySettingsStore(SettingsScope.UserSettings); _writeStore = _manager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!_writeStore.CollectionExists(_name)) { _writeStore.CreateCollection(_name); string defaults = string.Join(_separator, PreEnabledExtensions.List); _writeStore.SetString(_name, _identifierKey, defaults); } }
public string this[string key] { get { Throw.IfNull(key); return(userSettingsStore.GetString(CollectionName, key)); } set { Throw.IfNull(key); Throw.IfNull(value); userSettingsStore.SetString(CollectionName, key, value); } }
/// <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); HashSet <string> testedCollections = new HashSet <string>(); foreach (PropertyInfo property in GetOptionProperties()) { var collectionNameAttribute = property.GetCustomAttribute <OverrideCollectionNameAttribute>(); var collectionName = collectionNameAttribute?.CollectionName ?? this.CollectionName; var overrideDataTypeAttribute = property.GetCustomAttribute <OverrideDataTypeAttribute>(); var dataType = overrideDataTypeAttribute?.SettingDataType ?? SettingDataType.Serialized; if (!testedCollections.Contains(collectionName)) { if (!settingsStore.CollectionExists(collectionName)) { settingsStore.CreateCollection(collectionName); } testedCollections.Add(collectionName); } switch (dataType) { case SettingDataType.Serialized: var output = SerializeValue(property.GetValue(this)); settingsStore.SetString(collectionName, property.Name, output); break; case SettingDataType.Bool: var boolValue = (bool)property.GetValue(this); settingsStore.SetBoolean(collectionName, property.Name, boolValue); break; default: throw new ArgumentOutOfRangeException(); } } T liveModel = await GetLiveInstanceAsync(); if (this != liveModel) { await liveModel.LoadAsync(); } Saved?.Invoke(this, liveModel); }
private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { DataChanged?.Invoke(sender, e); if (_isLoading) { return; } var serializer = new JavaScriptSerializer(); var serializedValue = serializer.Serialize(ViewModel); _settingsStore.SetString("External Tools", "UWPAssetGenerator-SizeConstraints", serializedValue); }
/// <summary> /// Writes a user setting that prevents checking for compatibility for some number of days /// </summary> private static void DelayNextCheck() { DateTime nextTime = DateTime.UtcNow.AddDays(7); string nextTimeString = nextTime.ToString("u", CultureInfo.InvariantCulture); try { WritableSettingsStore store = UserConfigStore; store.CreateCollection("WebEssentials"); store.SetString("WebEssentials", "NextCompatibilityCheckDate", nextTimeString); } catch (ArgumentException) { Debug.Fail(@"Failed to set WebEssentials\NextCompatibilityCheckDate"); } }