/// <summary> /// Sets the autocorrect file path, or null if none. /// </summary> public void SetAutoCorrectFile(string path) { if (string.IsNullOrEmpty(path)) { finderFile = new AutoReplaceFinder(canMatch); return; } lock (_lock) { if (!finderFileCache.TryGetValue(path, out finderFile)) { AutoReplaceFinder newFinderFile = new AutoReplaceFinder(canMatch); using (Stream s = File.OpenRead(path)) { foreach (var pair in AutoCorrectLexiconReader.Read(s)) { newFinderFile.Add(NormalizeInputValue(pair.From), pair.To); } } finderFile = newFinderFile; finderFileCache.Add(path, finderFile); } } }
public void ReloadPhraseSettings() { lock (_lock) { AutoReplaceFinder newFinderRegistry = new AutoReplaceFinder(canMatch); foreach (var phrase in AutoreplaceSettings.AutoreplacePhrases) { newFinderRegistry.Add(NormalizeInputValue(phrase.Phrase), phrase.ReplaceValue); } finderRegistry = newFinderRegistry; } }