Пример #1
0
        /// <summary>
        /// Searching with regular expressions through bible texts that contain
        /// punctuation and foreign characters is no fun. This function strips
        /// out or replaces all the undesirables to make searching easier.
        /// </summary>
        /// <param name="verses">The bible text</param>
        /// <returns>The converted text</returns>
        private string Replace(string text)
        {
            if (_replacements == null)
            {
                return(DreamTools.RemoveNonAlpha(DreamTools.RemoveDiacritics(text)));
            }

            foreach (System.Data.DataRow r in _replacements.Rows)
            {
                // If the user entered an invalid regex, we need to trap it
                try {
                    text = Regex.Replace(text, r.ItemArray[0].ToString(), r.ItemArray[1].ToString());
                } catch { }
            }
            return(text);
        }
Пример #2
0
        /// <summary>
        /// Finds the first bible book that starts with the letters passed in.
        /// </summary>
        /// <param name="book">The letters the book starts with.</param>
        /// <returns>A number: 1-66, or -1 if no book starts with the letters passed in.</returns>
        public int BookNumber(string book)
        {
            int    i = 0;
            string bLC;

            book = DreamTools.RemoveDiacritics(book.ToLower());
            foreach (BibleBook b in BibleBooks)
            {
                bLC = DreamTools.RemoveDiacritics(b.Long.ToLower());
                if (bLC.StartsWith(book))
                {
                    return(i);
                }
                i++;
            }
            return(-1);
        }
Пример #3
0
        /// <summary>
        /// Returns a bible reference (ex. Genesis 4:7) after removing special
        /// characters from the book name.
        /// </summary>
        /// <param name="verseIdx"></param>
        /// <param name="Abbreviated">If true, returns the abbreviated name of the bible book</param>
        /// <returns></returns>
        public string GetSimpleRef(int verseIdx, bool Abbreviated)
        {
            if (verseIdx < 0 || verseIdx >= _VerseCount)
            {
                return("");
            }
            BibleVerse v = verses[verseIdx];

            if (Abbreviated)
            {
                return(string.Format("{0} {1}:{2}", DreamTools.RemoveDiacritics(BibleBooks[v.b].Short), v.c, v.v));
            }
            else
            {
                return(string.Format("{0} {1}:{2}", DreamTools.RemoveDiacritics(BibleBooks[v.b].Long), v.c, v.v));
            }
        }