Пример #1
0
        SpellDictionary CreateDictionary(string locale)
        {
            SpellDictionary res = new SpellDictionary(engine, locale, tempDisplayName);

            dicts.Add(res);
            return(res);
        }
Пример #2
0
        void SetPropertyDictionary(SpellDictionary dict, string format, string location)
        {
            string[] files = location.Split(new char[] { ' ' });
            string   aff   = string.Empty;
            string   dic   = string.Empty;
            string   idx   = string.Empty;
            string   dat   = string.Empty;

            foreach (string file in files)
            {
                string f = file.Replace("%origin%", this.tempLocalDir).Replace('/', '\\');
                switch (Path.GetExtension(f).ToLowerInvariant())
                {
                case ".aff":
                    aff = f;
                    break;

                case ".dic":
                    dic = f;
                    break;

                case ".dat":
                    dat = f;
                    break;

                case ".idx":
                    idx = f;
                    break;
                }
            }

            switch (format)
            {
            case "DICT_SPELL":
                dict.SetSpellFiles(aff, dic);
                break;

            case "DICT_HYPH":
                dict.SetHyphFiles(dic);
                break;

            case "DICT_THES":
                if (string.IsNullOrEmpty(idx))
                {
                    string new_idx = dat.Replace(Path.GetExtension(dat), ".idx");
                    if (File.Exists(new_idx))
                    {
                        idx = new_idx;
                    }
                }

                dict.SetThesFiles(dat, idx);
                break;
            }
        }
Пример #3
0
        void LoadPropertyDictionary(XmlNodeList nodes)
        {
            string loc    = string.Empty;
            string format = string.Empty;
            string locale = string.Empty;

            foreach (XmlNode node in nodes)
            {
                foreach (XmlAttribute attr in node.Attributes)
                {
                    if (attr.Name == Strings.NodeAttributeName)
                    {
                        switch (attr.Value)
                        {
                        case "Locations":
                            loc = GetValueNode(node.ChildNodes);
                            break;

                        case "Format":
                            format = GetValueNode(node.ChildNodes);
                            break;

                        case "Locales":
                            locale = GetValueNode(node.ChildNodes);
                            break;
                        }
                    }
                }
            }

            // получим все локали для словаря
            string[] locales = locale.Split(new char[] { ' ' });
            foreach (string l in locales)
            {
                SpellDictionary dict = GetDictionary(l) ?? CreateDictionary(l);
                SetPropertyDictionary(dict, format, loc);
            }
        }