Source

Resharper Spell Checker / ReSpeller / SpellEngine / Dictionaries / HunspellDictionaryFactory.cs

using System.IO;

namespace ReSpeller.SpellEngine.Dictionaries
{
  public class HunspellDictionaryFactory : IDictionaryFactory
  {
    private readonly string myMainDictionariesDir;
    private readonly string myUserDictionariesDir;


    public HunspellDictionaryFactory(string mainDictionariesDir, string userDictionariesDir)
    {
      myMainDictionariesDir = mainDictionariesDir;
      myUserDictionariesDir = userDictionariesDir;
    }

    public IUserInternalDictionary CreateDictionary(string language)
    {
      var userStorage = new FileDictionaryStorage(Path.Combine(myUserDictionariesDir, language + "." + Constants.DictExt));
      var internalStorage = new FileDictionaryStorage(Path.Combine(myMainDictionariesDir, language + Constants.InternalDictSuffix + "." + Constants.DictExt));
      HunspellEngine hunspellEngine = HunspellEngine.CreateForLanguage(Constants.MainDictDir, language);
      return new UserInternalDictionary(hunspellEngine, language, userStorage, internalStorage);
    }
  }
}