/// <summary> /// Loads the entire KJV Bible into memory. /// </summary> internal void LoadBibleIntoMemory() { int currentBook = 0; string book, word, lastBook = string.Empty; int chapter, verse = 0; using (StreamReader r = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("BibleProject.BibleFlatFiles.English.kjvdat.txt"))) { string CurrentLine = String.Empty; while ((CurrentLine = r.ReadLine()) != null) { book = CurrentLine.Split('|')[0]; chapter = Convert.ToInt32(CurrentLine.Split('|')[1]); verse = Convert.ToInt32(CurrentLine.Split('|')[2]); word = CurrentLine.Split('|')[3].Split('~')[0]; if (!String.IsNullOrEmpty(lastBook) && lastBook != book) // lastBook was set, but it's not the same as the current book. { currentBook++; MemoryStorage.BookList.Add(new BookCollection(currentBook, TextConverters.GetBookNameFromAbbreviation(book))); } else if (String.IsNullOrEmpty(lastBook)) // Last book was not set. Insert book name. { MemoryStorage.BookList.Add(new BookCollection(currentBook, TextConverters.GetBookNameFromAbbreviation(book))); } MemoryStorage.Bible.Add(new BibleCollection(currentBook, chapter, verse, word)); lastBook = book; } MemoryStorage.FullDataCollection.Add(new FullCollection(MemoryStorage.Bible, MemoryStorage.BookList)); } }