//===================================================================== /// <summary> /// Private constructor /// </summary> /// <param name="culture">The language to use for the dictionary</param> /// <param name="spellFactory">The spell factory to use when checking words</param> /// <param name="dictionaryFile">The dictionary file</param> /// <param name="userWordsFile">The user dictionary words file</param> /// <param name="serviceProvider">A service provider for interacting with the solution/project</param> private GlobalDictionary(CultureInfo culture, SpellFactory spellFactory, string dictionaryFile, string userWordsFile, IServiceProvider serviceProvider) { this.culture = culture; this.spellFactory = spellFactory; this.dictionaryFile = dictionaryFile; this.serviceProvider = serviceProvider; if(String.IsNullOrWhiteSpace(dictionaryFile)) throw new ArgumentException("Dictionary filename cannot be null or empty", "dictionaryFile"); registeredServices = new List<WeakReference>(); dictionaryWords = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase); if(String.IsNullOrWhiteSpace(userWordsFile)) dictionaryWordsFile = Path.Combine(SpellingConfigurationFile.GlobalConfigurationFilePath, culture.Name + "_User.dic"); else dictionaryWordsFile = userWordsFile; ignoredWords = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase); recognizedWords = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase); this.LoadUserDictionaryFile(); }
//===================================================================== /// <summary> /// Private constructor /// </summary> /// <param name="culture">The language to use for the dictionary</param> /// <param name="spellFactory">The spell factory to use when checking words</param> private GlobalDictionary(CultureInfo culture, SpellFactory spellFactory) { this.Language = culture; this.spellFactory = spellFactory; ignoredWords = new HashSet<string>(StringComparer.OrdinalIgnoreCase); ignoredWordsFile = Path.Combine(SpellCheckerConfiguration.ConfigurationFilePath, culture.Name + "_Ignored.dic"); this.LoadIgnoredWordsFile(); }
/// <summary> /// Adds the language. /// </summary> /// <param name="config"> /// The language configuration. /// </param> public void AddLanguage(LanguageConfig config) { string languageCode = config.LanguageCode; languageCode = languageCode.ToLower(); if (config.Processors < 1) { config.Processors = this.Processors; } var factory = new SpellFactory(config); lock (this.dictionaryLock) this.languages.Add(languageCode, factory); }
//===================================================================== /// <inheritdoc /> public void Dispose() { if(spellFactory != null) { spellFactory.Dispose(); spellFactory = null; registeredServices.Clear(); } }