public static void Save() { settings.SetString(collectionName, nameof(ResourcesFolderName), ResourcesFolderName); settings.SetString(collectionName, nameof(ResourcesManagerName), ResourcesManagerName); settings.SetBoolean(collectionName, nameof(UseStaticResourceXAML), UseStaticResourceXAML); settings.SetBoolean(collectionName, nameof(SetLocaleOnStartup), SetLocaleOnStartup); }
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 Save() { if (!_store.CollectionExists(COLLECTION_PATH)) { _store.CreateCollection(COLLECTION_PATH); } _store.SetBoolean(COLLECTION_PATH, IS_DESIGNER_ENABLED_PROPERTY, IsDesignerEnabled); _store.SetBoolean(COLLECTION_PATH, IS_REVERSED_PROPERTY, IsReversed); _store.SetInt32(COLLECTION_PATH, SPLIT_ORIENTATION_PROPERTY, (int)SplitOrientation); _store.SetInt32(COLLECTION_PATH, DOCUMENT_VIEW_PROPERTY, (int)DocumentView); }
private static bool GetBooleanProperty(WritableSettingsStore store, string propertyName, bool defaultValue) { try { if (!store.PropertyExists(CollectionName, propertyName)) { store.SetBoolean(CollectionName, propertyName, defaultValue); } return(store.GetBoolean(CollectionName, propertyName)); } catch { store.SetBoolean(CollectionName, propertyName, defaultValue); return(defaultValue); } }
/// <summary> /// Saves DexterInfo to Settings Store /// </summary> /// <param name="dexterInfo">DexterInfo to save</param> public void Save(DexterInfo dexterInfo) { if (!settingsStore.CollectionExists(DexterStoreName)) { settingsStore.CreateCollection(DexterStoreName); } settingsStore.SetString(DexterStoreName, "dexterHome", dexterInfo.dexterHome); settingsStore.SetString(DexterStoreName, "dexterServerIp", dexterInfo.dexterServerIp); settingsStore.SetInt32(DexterStoreName, "dexterServerPort", dexterInfo.dexterServerPort); settingsStore.SetString(DexterStoreName, "userName", dexterInfo.userName); settingsStore.SetString(DexterStoreName, "userPassword", dexterInfo.userPassword); settingsStore.SetBoolean(DexterStoreName, "standalone", dexterInfo.standalone); settingsStore.SetBoolean(DexterStoreName, "isDexterHomeEnabled", dexterInfo.IsDexterHomeEnabled); }
/// <summary> /// This is used to save the MEF provider configuration settings /// </summary> /// <remarks>The settings are saved using the <see cref="ShellSettingsManager"/> to the /// <see cref="CollectionPath"/> collection.</remarks> public bool SaveConfiguration() { ShellSettingsManager settingsManager = new ShellSettingsManager(_serviceProvider); WritableSettingsStore 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, "EnableGoToDefinitionInCRef", EnableGoToDefinitionInCRef); return(true); }
public static void WriteSetting <T>(string propertyName, T propertyValue) { switch (Type.GetTypeCode(typeof(T))) { case TypeCode.String: _userSettingsStore.SetString(CollectionName, propertyName, Convert.ToString(propertyValue)); break; case TypeCode.Boolean: _userSettingsStore.SetBoolean(CollectionName, propertyName, Convert.ToBoolean(propertyValue)); break; case TypeCode.Int32: _userSettingsStore.SetInt32(CollectionName, propertyName, Convert.ToInt32(propertyValue)); break; case TypeCode.Int64: _userSettingsStore.SetInt64(CollectionName, propertyName, Convert.ToInt64(propertyValue)); break; case TypeCode.UInt32: _userSettingsStore.SetUInt32(CollectionName, propertyName, Convert.ToUInt32(propertyValue)); break; case TypeCode.UInt64: _userSettingsStore.SetUInt64(CollectionName, propertyName, Convert.ToUInt64(propertyValue)); break; default: _userSettingsStore.SetString(CollectionName, propertyName, Convert.ToString(propertyValue)); break; } }
public void Write(string subPath, string property, object value) { Validate.IsNotNull(property, nameof(property)); Validate.IsNotEmpty(property, nameof(property)); var collection = subPath != null?Path.Combine(_root, subPath) : _root; _store.CreateCollection(collection); if (value is bool b) { _store.SetBoolean(collection, property, b); } else if (value is int i) { _store.SetInt32(collection, property, i); } else if (value is uint u) { _store.SetUInt32(collection, property, u); } else if (value is long l) { _store.SetInt64(collection, property, l); } else if (value is ulong ul) { _store.SetUInt64(collection, property, ul); } else { _store.SetString(collection, property, value?.ToString() ?? ""); } }
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); } } }
private static bool SaveSettingsIntoStore(ISettings settings) { var saved = false; var properties = GetProperties(settings); foreach (var prop in properties) { switch (prop.GetValue(settings)) { case bool b: store.SetBoolean(settings.Key, prop.Name, b); saved = true; break; case int i: store.SetInt32(settings.Key, prop.Name, i); saved = true; break; case double d: store.SetString(settings.Key, prop.Name, d.ToString()); saved = true; break; case string s: store.SetString(settings.Key, prop.Name, s); saved = true; break; } } return(saved); }
public void Write(string subpath, string property, object value) { Guard.ArgumentNotNull(property, nameof(property)); Guard.ArgumentNotEmptyString(property, nameof(property)); var collection = subpath != null?Path.Combine(root, subpath) : root; store.CreateCollection(collection); if (value is bool) { store.SetBoolean(collection, property, (bool)value); } else if (value is int) { store.SetInt32(collection, property, (int)value); } else if (value is uint) { store.SetUInt32(collection, property, (uint)value); } else if (value is long) { store.SetInt64(collection, property, (long)value); } else if (value is ulong) { store.SetUInt64(collection, property, (ulong)value); } else { store.SetString(collection, property, value?.ToString() ?? ""); } }
private void Set(string key, object value, Type targetType = null, SerializationMode serializationMode = SerializationMode.Xml) { if (targetType == null) { if (value is int && (int)value == 0) { value = false; targetType = typeof(bool); } else if (value is int && (int)value == 1) { value = true; targetType = typeof(bool); } else { targetType = ConvertSettingsType(Check.TryCatch <SettingsType, Exception>(() => settingsStore.GetPropertyType(collectionPath, key)), value?.GetType()); } } if (targetType.IsEnum) { targetType = typeof(int); } if (targetType == typeof(bool)) { settingsStore.SetBoolean(collectionPath, key, Convert.ToBoolean(value)); } else if (targetType == typeof(string)) { var s = value?.ToString() ?? string.Empty; settingsStore.SetString(collectionPath, key, s); } else if (targetType == typeof(int)) { settingsStore.SetInt32(collectionPath, key, Convert.ToInt32(value)); } else { using (var ms = new MemoryStream()) { if (serializationMode == SerializationMode.Binary) { var serializer = new BinaryFormatter(); serializer.Serialize(ms, value); ms.Position = 0; settingsStore.SetMemoryStream(collectionPath, key, ms); } else if (serializationMode == SerializationMode.Xml) { var serializer = new XmlSerializer(targetType); serializer.Serialize(ms, value); string xmlContent = Encoding.UTF8.GetString(ms.ToArray()); settingsStore.SetString(collectionPath, key, xmlContent); } } } }
private static void SetOption(WritableSettingsStore store, string catelogName, string optionName, bool value) { if (!store.CollectionExists(COLLECTION_PATH)) { store.CreateCollection(COLLECTION_PATH); } store?.SetBoolean(COLLECTION_PATH, CombineCatelogAndOptionName(catelogName, optionName), value); }
private static void SaveBoolean(OptionName.SettingIds name, bool variableValue, WritableSettingsStore settingsStore) { if (!settingsStore.CollectionExists(defaultCollectionPath)) { settingsStore.CreateCollection(defaultCollectionPath); } settingsStore.SetBoolean(defaultCollectionPath, name.ToString(), variableValue); }
internal static void WriteBoolean(this WritableSettingsStore settingsStore, string collectionName, string propertyName, bool value) { if (!settingsStore.CollectionExists(collectionName)) { settingsStore.CreateCollection(collectionName); } settingsStore.SetBoolean(collectionName, propertyName, value); }
public static void SaveCurrent() { if (!settingsStore.CollectionExists(CollectionPath)) { settingsStore.CreateCollection(CollectionPath); } settingsStore.SetBoolean(CollectionPath, "IsEnabled", Current.IsEnabled); }
/// <summary> /// Writes a boolean value to the settings store /// </summary> /// <param name="value"></param> /// <param name="propertyName"></param> private void WriteBoolean(bool value, [CallerMemberName] string propertyName = null) { if (!_store.CollectionExists(SETTINGS_PATH)) { _store.CreateCollection(SETTINGS_PATH); } _store.SetBoolean(SETTINGS_PATH, propertyName, value); }
private static void Execute(OleMenuCommand menuItem) { var enabled = !menuItem.Checked ? (uint)1 : 0; _debugger.SetDebuggerOption(DEBUGGER_OPTIONS.Option_JustMyCode, enabled); WritableSettingsStore store = _settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); store.SetBoolean("Debugger", "JustMyCode", !menuItem.Checked); }
public void SetBoolean(string propertyName, bool val) { try { _settingsStore.SetBoolean(CollectionPath, propertyName, val); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
/// <summary> /// Writes Crm Connection to settings store /// </summary> /// <param name="crmConnections">Crm Connections to write to settings store</param> private void SetCrmConnections(CrmConnections crmConnections) { if (crmConnections?.Connections == null) { _settingsStore.DeletePropertyIfExists(CollectionPath, ConnectionsPropertyName); return; } Dictionary <Guid, string> passwordCache = new Dictionary <Guid, string>(); foreach (var connection in crmConnections.Connections) { if (connection.ConnectionId != null && !passwordCache.ContainsKey(connection.ConnectionId.Value)) { passwordCache.Add(connection.ConnectionId.Value, connection.UserPassword); } if (!string.IsNullOrEmpty(connection.UserPassword) && connection.SavePassword) { connection.UserPassword = EncryptString(connection.UserPassword); } else { connection.UserPassword = null; } } var connectionsXml = XmlSerializerHelper.Serialize(crmConnections.Connections); _settingsStore.SetString(CollectionPath, ConnectionsPropertyName, connectionsXml); _settingsStore.SetBoolean(CollectionPath, AutoPublishPropertyName, crmConnections.PublishAfterUpload); _settingsStore.SetBoolean(CollectionPath, IgnoreExtensionsProprtyName, crmConnections.IgnoreExtensions); _settingsStore.SetBoolean(CollectionPath, ExtendedLogProprtyName, crmConnections.ExtendedLog); foreach (var connection in crmConnections.Connections) { if (connection.ConnectionId != null && passwordCache.ContainsKey(connection.ConnectionId.Value)) { connection.UserPassword = passwordCache[connection.ConnectionId.Value]; } } }
public static void SetBoolean(string option, bool value) { Initialize(); defaults[option] = value; if (persistent_settings == null) { return; } IEnumerable <string> collection = persistent_settings.GetSubCollectionNames("AntlrVSIX"); persistent_settings.SetBoolean("AntlrVSIX", option, value); }
public static void InitWritableSettings(this WritableSettingsStore settingsStore) { if (!settingsStore.CollectionExists(PackageSettingsCategory)) { settingsStore.CreateCollection(PackageSettingsCategory); } if (!settingsStore.PropertyExists(PackageSettingsCategory, PackageReadyPropertyName)) { settingsStore.SetBoolean(PackageSettingsCategory, PackageReadyPropertyName, false); } }
internal void SetBoolean(string propertyName, bool value) { EnsureCollectionExists(); try { _settingsStore.SetBoolean(CollectionPath, propertyName, value); } catch (Exception e) { Report(String.Format(ErrorSetFormat, propertyName), e); } }
public void SaveSettings() { try { SettingsManager settingsManager = new ShellSettingsManager(this.ServiceProvider); WritableSettingsStore settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); settingsStore.SetBoolean(COLLECTION_GROUP, DISPLAY_ON_BUILD_START, this.PluginSettings.DisplayOnBuildStart); settingsStore.SetBoolean(COLLECTION_GROUP, DISPLAY_ON_SOLUTION_CHANGE, this.PluginSettings.DisplayOnSolutionChange); settingsStore.SetBoolean(COLLECTION_GROUP, DISPLAY_ON_STARTUP, this.PluginSettings.DisplayOnStartup); settingsStore.SetBoolean(COLLECTION_GROUP, OVERRIDE_VS_OUTPUT_WINDOW, this.PluginSettings.OverrideVSOutputWindow); settingsStore.SetBoolean(COLLECTION_GROUP, ENABLE_QUICK_SYNC, this.PluginSettings.EnableQuickSync); CustomColumnInfoCompressor compressor = new CustomColumnInfoCompressor(); string visualContents = compressor.Compress(this.PluginSettings.VisualSettings); settingsStore.SetString(COLLECTION_GROUP, VISUAL_SETTINGS, visualContents); } catch (Exception e) { // Do nothing } }
private void AdornmentVisibilityChanged(object sender, bool isVisible) { WritableSettingsStore wstore = _settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); _isVisible = isVisible; if (!wstore.CollectionExists(Constants.CONFIG_FILENAME)) { wstore.CreateCollection(Constants.CONFIG_FILENAME); } wstore.SetBoolean(Constants.CONFIG_FILENAME, _propertyName, isVisible); }
private static void EnableLoadingAllExtensions(WritableSettingsStore settingsStore) { const string EnableAdminExtensionsProperty = "EnableAdminExtensions"; if (!settingsStore.CollectionExists(ExtensionManagerCollectionPath)) { settingsStore.CreateCollection(ExtensionManagerCollectionPath); } if (!settingsStore.GetBoolean(ExtensionManagerCollectionPath, EnableAdminExtensionsProperty, defaultValue: false)) { settingsStore.SetBoolean(ExtensionManagerCollectionPath, EnableAdminExtensionsProperty, value: true); } }
/// <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); }
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)); settingsStore.SetBoolean(COLLECTION_PATH, nameof(FontSettings.HighlightKeywordsOnly), CurrentSettings.HighlightKeywordsOnly); settingsStore.SetBoolean(COLLECTION_PATH, nameof(FontSettings.UnderlineImportantComments), CurrentSettings.UnderlineImportantComments); SettingsSaved?.Invoke(null, EventArgs.Empty); } catch (Exception ex) { Debug.Fail(ex.Message); } }
public static void SaveSettings(ISettings settings) { try { if (store.CollectionExists(settings.Key) != true) { store.CreateCollection(settings.Key); } var anySaved = false; var type = settings.GetType(); foreach (var prop in type.GetProperties().Where(p => Attribute.IsDefined(p, typeof(SettingAttribute)))) { if (prop.PropertyType == typeof(bool)) { store.SetBoolean(settings.Key, prop.Name, ((bool)(prop.GetValue(settings)))); anySaved = true; } else if (prop.PropertyType == typeof(int)) { store.SetInt32(settings.Key, prop.Name, ((int)(prop.GetValue(settings)))); anySaved = true; } else if (prop.PropertyType == typeof(double)) { store.SetString(settings.Key, prop.Name, prop.GetValue(settings).ToString()); anySaved = true; } else if (prop.PropertyType == typeof(string)) { store.SetString(settings.Key, prop.Name, ((string)(prop.GetValue(settings)))); anySaved = true; } } if (anySaved) { SettingsChanged?.Invoke(); } } catch (Exception ex) { Debug.Fail(ex.Message); } }
private void AutoScroll_OnClick(object sender, RoutedEventArgs e) { IsAutoScroll = !IsAutoScroll; if (IsAutoScroll) { Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll On"; }); } else { Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll Off"; }); } SettingsManager settingsManager = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider); WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); configurationSettingsStore.CreateCollection(LogcatOutputToolWindowControl.StoreCategoryName); configurationSettingsStore.SetBoolean(StoreCategoryName, StorePropertyAutoScrollName, IsAutoScroll); }