コード例 #1
0
 /// <summary>
 /// Returns the book of the Bible with the supplied name
 /// </summary>
 public static Book Get(BibleBooks bookName)
 {
     if (bible.ContainsKey(bookName))
     {
         return(bible[bookName]);
     }
     return(bible[BibleBooks.Genesis]);
 }
コード例 #2
0
        public override async void Init(object initData)
        {
            BibleBooks = WolLibrary.GetAllBibleBooks();

            int langid = (Settings.PrimaryLanguage == LPLanguage.English.GetName()) ? (int)Language.English : (int)Language.Chinese;

            HebrewBibleBooks = new ObservableCollection <BibleBook>(BibleBooks.Where(b => b.MepsLanguageId == langid).Take(39));
            GreekBibleBooks  = new ObservableCollection <BibleBook>(BibleBooks.Where(b => b.MepsLanguageId == langid).Skip(39));

            Title = App.GetLanguageValue("New World Translation", "新世界译本");
        }
コード例 #3
0
        private static IDictionary <BibleBooks, Book> BuildBible()
        {
            IDictionary <BibleBooks, Book> books = new Dictionary <BibleBooks, Book>();
            List <BibleBooks> BibleNames         = BookChapters.Keys.ToList();
            string            documents          = "";

#if DEBUG
            documents = @"..\..\..\MyTextSummarizer\Documents";
#else
            documents = @".\Documents";
#endif
            int bkInd = 0;
            foreach (string path in Directory.EnumerateFiles(documents))
            {
                IDictionary <int, Chapter> chapters = new Dictionary <int, Chapter>();

                string     text = System.IO.File.ReadAllText(path);
                BibleBooks book = BibleNames[bkInd];

                // Break the book into chapters
                for (int chap = 1; chap <= BookChapters[book]; chap++)
                {
                    IDictionary <int, Verse> verses = new Dictionary <int, Verse>();

                    // This regex will get verses that start with this chapter number
                    string regexPattern = string.Format(@"{0}:[\d]+[\D]*", chap);

                    int verseNum = 1;
                    foreach (var verse in Regex.Matches(text, regexPattern))
                    {
                        // This prevents including chapter "11:1" as "1:1"
                        int txtVerse = Int32.Parse(verse.ToString().Split(':')[1].Split(' ')[0]);
                        if (txtVerse < verseNum)
                        {
                            break;
                        }

                        verses[verseNum] = new Verse(verse.ToString());
                        verseNum++;
                    }
                    chapters[chap] = new Chapter(verses);
                }
                books[book] = new Book(chapters);

                // This prevents it from trying to add the entire bible
                bkInd++;
                if (bkInd == 66)
                {
                    break;
                }
            }
            return(books);
        }