private void AddItem(string key, string text) { WhitespaceListItem item = new WhitespaceListItem() { Key = key, Text = text }; item.Newlines = _settingsStore.GetIndexedValue <ReflowAndRetagSettings, string, int>(x => x.WhitespaceNewlineSettings, item.Key + "OnNewLine"); item.Indent = _settingsStore.GetIndexedValue <ReflowAndRetagSettings, string, bool>(x => x.WhitespaceIndentSettings, item.Key + "Indent"); WhitespaceListItems.Add(item); }
public static IEnumerable <string> GetAdditionalConfigurationFiles( this IContextBoundSettingsStore optionsContext, string solutionId) { var customConfigurationFilesJson = optionsContext.GetIndexedValue( ConfigurationSenseSettingsAccessor.CustomConfigurationFiles, solutionId); if (string.IsNullOrEmpty(customConfigurationFilesJson)) { return(Enumerable.Empty <string>()); } try { return(JsonConvert.DeserializeObject <HashSet <string> >(customConfigurationFilesJson)); } // ReSharper disable once CatchAllClause catch (Exception) { optionsContext.SetIndexedValue( ConfigurationSenseSettingsAccessor.CustomConfigurationFiles, solutionId, string.Empty); return(Enumerable.Empty <string>()); } }
public void Execute(ISolution solution, ITextControl textControl) { ISettingsStore store = Shell.Instance.GetComponent <ISettingsStore>(); // Get the dictionary CustomDictionary dictionary = _settingsStore.GetIndexedValue <CustomDictionarySettings, string, CustomDictionary>( settings => settings.CustomDictionaries, _dictName); if (dictionary == null) { dictionary = new CustomDictionary() { Name = _dictName } } ; string words = dictionary.DecodedUserWords.Trim(); if (words.Length > 0) { dictionary.DecodedUserWords = words + "\n"; } dictionary.DecodedUserWords += _word; IContextBoundSettingsStore boundStore = store.BindToContextTransient(ContextRange.ApplicationWide); boundStore.SetIndexedValue <CustomDictionarySettings, string, CustomDictionary>(x => x.CustomDictionaries, _dictName, dictionary); SpellCheckManager.Reset(); // Clear the cache. solution.SaveSettings(); Daemon.GetInstance(solution).ForceReHighlight(_documentRange.Document); }
private static ClrUserDefinedNamingRule GetUnitySerializedFieldRule(IContextBoundSettingsStore settingsStore, SettingsIndexedEntry entry) { var userRule = settingsStore.GetIndexedValue(entry, UnityNamingRuleDefaultSettings.SerializedFieldRuleGuid, null) as ClrUserDefinedNamingRule; if (userRule == null) { userRule = UnityNamingRuleDefaultSettings.GetUnitySerializedFieldRule(); SetUnitySerializedFieldRule(settingsStore, entry, userRule); } return(userRule); }
public static bool IsCodeVisionEnabled(IContextBoundSettingsStore settings, string providerId, Action fallback, out bool useFallback) { useFallback = false; if (settings.GetIndexedValue((CodeInsightsSettings key) => key.DisabledProviders, providerId)) { fallback(); useFallback = true; return(false); } if (settings.GetValue((UnitySettings key) => key.GutterIconMode) == GutterIconMode.Always) { fallback(); useFallback = true; } return(true); }
private static SpellChecker loadSpellChecker(IContextBoundSettingsStore settingsStore, string name, ISolution solution) { string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), String.Format("Agent Smith\\dic\\{0}.dic", name)); if (!File.Exists(path)) { path = GetDictPath(name); if (!File.Exists(path)) { return(null); } } try { using (TextReader reader = File.OpenText(path)) { WordDictionary dictionary = new WordDictionary(reader); CustomDictionary customDictionary = settingsStore.GetIndexedValue <CustomDictionarySettings, string, CustomDictionary>(x => x.CustomDictionaries, name); if (customDictionary == null) { customDictionary = new CustomDictionary() { Name = name }; } return(new SpellChecker(dictionary, customDictionary)); } } catch (Exception ex) { Logger.LogError("Failed to load dictionary from path {0},{1}", path, ex.ToString()); return(null); } }