internal override void SaveSettings() { base.SaveSettings(); var namingPreferencesXml = _viewModel.GetInfo().CreateXElement().ToString(); var oldOptions = OptionService.GetOptions(); var newOptions = oldOptions.WithChangedOption(SimplificationOptions.NamingPreferences, _languageName, namingPreferencesXml); OptionService.SetOptions(newOptions); OptionLogger.Log(oldOptions, newOptions); }
internal void SetCodeCleanupAsConfigured() { var areCodeCleanupRulesConfigured = OptionService.GetOption <bool>(CodeCleanupOptions.AreCodeCleanupRulesConfigured, LanguageNames.CSharp); if (!areCodeCleanupRulesConfigured) { var oldOptions = OptionService.GetOptions(); var newOptions = oldOptions.WithChangedOption(CodeCleanupOptions.AreCodeCleanupRulesConfigured, LanguageNames.CSharp, true); OptionService.SetOptions(newOptions); OptionLogger.Log(oldOptions, newOptions); } }
internal override void SaveSettings() { base.SaveSettings(); // once formatting option is explicitly set (regardless codeclean is on or off), // we never show code cleanup info bar again var oldOptions = OptionService.GetOptions(); var newOptions = oldOptions.WithChangedOption( CodeCleanupOptions.NeverShowCodeCleanupInfoBarAgain, LanguageNames.CSharp, value: true); OptionService.SetOptions(newOptions); OptionLogger.Log(oldOptions, newOptions); }
public bool Restore(OptionItem item) { if (item == null) { return(false); } try { string name = item.GetStoreKey(); OptionLogger.AddTrace(" Option: " + name); PersistentNameLookup names = GetExisting(item.GetType()); if (names == null) { OptionLogger.AddError(" No Name"); return(false); } PersistentOption option = names.Get(name); if (option == null) { OptionLogger.AddError(" No Option"); return(false); } try { if (option.mValue != null) { item.PersistValue = option.mValue; } return(true); } catch (InvalidCastException e) { Common.DebugException(item.GetStoreKey() + ": " + option.mValue + " (" + option.mValue.GetType() + ")", e); OptionLogger.AddError(" Casting Fail"); return(false); } } catch (Exception e) { Common.Exception(item.GetStoreKey(), e); OptionLogger.AddError(" Exception"); return(false); } }
internal override void SaveSettings() { var symbolSpecifications = ArrayBuilder <SymbolSpecification> .GetInstance(); var namingRules = ArrayBuilder <SerializableNamingRule> .GetInstance(); var namingStyles = ArrayBuilder <NamingStyle> .GetInstance(); foreach (var item in _viewModel.CodeStyleItems) { if (!item.IsComplete()) { continue; } var rule = new SerializableNamingRule() { EnforcementLevel = item.SelectedNotificationPreference.Notification.Value, NamingStyleID = item.SelectedStyle.ID, SymbolSpecificationID = item.SelectedSpecification.ID }; namingRules.Add(rule); } foreach (var item in _viewModel.Specifications) { symbolSpecifications.Add(item); } foreach (var item in _viewModel.NamingStyles) { namingStyles.Add(item.NamingStyle); } var info = new NamingStylePreferences( symbolSpecifications.ToImmutableAndFree(), namingStyles.ToImmutableAndFree(), namingRules.ToImmutableAndFree()); var oldOptions = OptionService.GetOptions(); var newOptions = oldOptions.WithChangedOption(SimplificationOptions.NamingPreferences, _languageName, info); OptionService.SetOptions(newOptions); OptionLogger.Log(oldOptions, newOptions); }
internal override void SaveSettings() { var info = new SerializableNamingStylePreferencesInfo(); foreach (var item in _viewModel.CodeStyleItems) { if (!item.IsComplete()) { continue; } var rule = new SerializableNamingRule() { EnforcementLevel = item.SelectedNotificationPreference.Value, NamingStyleID = item.SelectedStyle.ID, SymbolSpecificationID = item.SelectedSpecification.ID }; info.NamingRules.Add(rule); } foreach (var item in _viewModel.Specifications) { info.SymbolSpecifications.Add(item); } foreach (var item in _viewModel.NamingStyles) { info.NamingStyles.Add(item); } var oldOptions = OptionService.GetOptions(); var newOptions = oldOptions.WithChangedOption(SimplificationOptions.NamingPreferences, _languageName, info.CreateXElement().ToString()); OptionService.SetOptions(newOptions); OptionLogger.Log(oldOptions, newOptions); }