Ejemplo n.º 1
0
        static Actor()
        {
            // home directory, for libraries and dictionaries
            var home = Path.GetDirectoryName(typeof(Hunspell).Assembly.Location);

            //! catch `Native Library is already loaded`, e.g. loaded by another module
            try { Hunspell.NativeDllPath = home; }
            catch (InvalidOperationException ex) { Log.TraceException(ex); }

            // initialize dictionaries
            foreach (var dir in Directory.GetDirectories(home))
            {
                foreach (var aff in Directory.GetFiles(dir, "*.aff"))
                {
                    var dic = Path.ChangeExtension(aff, ".dic");
                    if (File.Exists(dic))
                    {
                        var language = new DictionaryInfo()
                        {
                            HunspellAffFile = aff, HunspellDictFile = dic, Language = Path.GetFileName(dir)
                        };
                        Dictionaries.Add(language);

                        foreach (var dat in Directory.GetFiles(dir, "*.dat"))
                        {
                            language.MyThesDatFile = dat;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static bool Initialize()
        {
            // home directory, for libraries and dictionaries
            var home = Path.GetDirectoryName(typeof(Hunspell).Assembly.Location);

            //! catch `Native Library is already loaded`, e.g. loaded by another module
            try { Hunspell.NativeDllPath = home; }
            catch (InvalidOperationException ex) { Log.TraceException(ex); }

            // initialize dictionaries
            foreach (var dir in Directory.GetDirectories(home))
            {
                foreach (var aff in Directory.GetFiles(dir, "*.aff"))
                {
                    var dic = Path.ChangeExtension(aff, ".dic");
                    if (File.Exists(dic))
                    {
                        var language = new DictionaryInfo() { HunspellAffFile = aff, HunspellDictFile = dic, Language = Path.GetFileName(dir) };
                        Dictionaries.Add(language);

                        foreach (var dat in Directory.GetFiles(dir, "*.dat"))
                            language.MyThesDatFile = dat;
                    }
                }
            }

            return true;
        }