Example #1
0
        public static SortedDictionary <string, string> LoadNames(string lang, string path)
        {
            var sd = new SortedDictionary <string, string>();

            path = FileIO.GetFileName(path, App.RootPath);
            var file = File.ReadAllText(path);

            if (lang == "en")
            {
                EngBookNames.Clear();
            }
            foreach (var fl in file.Split('\n').Select(x => x.TrimNullIfEmpty()))
            {
                if (fl == null)
                {
                    continue;
                }
                var fn = fl.Split(':').Select(x => x.TrimNullIfEmpty()).Where(x => x.IsNotNullOrEmpty()).ToArray();
                if (fn.Length != 2)
                {
                    throw new SysException($"File {path} contains bad line: {fl}");
                }
                sd[fn[0]] = fn[1];
                if (lang == "en")
                {
                    var ma = RE_CHVERSE.Match(fn[1]);
                    if (ma != null)
                    {
                        var nm = new BibleName()
                        {
                            Id     = fn[0],
                            Volume = ma.Groups[1].Value.ToIntOrZero(),
                            Suffix = ma.Groups[2].Value.TrimNullIfEmpty(),
                            Full   = fn[1],
                        };
                        EngBookNames[nm.Id] = nm;
                    }
                }
            }
            BookNames[lang] = sd;
            return(sd);
        }
Example #2
0
        public static BibleIndexRequest ParseRequest(string text)
        {
            var ma  = RE_CHVERSE.Match(text);
            var req = new BibleIndexRequest()
            {
                SearchText = text
            };

            if (ma == null)
            {
                return(req);
            }
            req.Volume  = ma.Groups[1].Value.ToIntOrZero();
            req.Prefix  = ma.Groups[2].Value.ToLower().Trim();
            req.Chapter = ma.Groups[3].Value.ToIntOrZero();
            req.Verse   = ma.Groups[4].Value.ToIntOrZero();
            req.Range   = ma.Groups[5].Value.ToIntOrZero();
            if (req.Chapter < 1)
            {
                req.Chapter = 1;
            }
            return(req);
        }