public int GetBibleChaptersCount(XMLBIBLE bibleInfo, bool addBooksCount) { int result = bibleInfo.Books.Sum(b => b.Chapters.Count); if (addBooksCount) { result += bibleInfo.Books.Count; } return(result); }
private static void ConvertTextModule(string filePath) { List <BIBLEBOOK> books = new List <BIBLEBOOK>(); List <CHAPTER> chapters = null; List <VERS> verses = null; BIBLEBOOK latestBook = null; CHAPTER latestChapter = null; foreach (var line in File.ReadAllLines(filePath, Encoding.UTF8)) //GetEncoding("EUC-KR"))) { try { var verse = GetVerse(line, out string verseText); if (verse == null) { verses.Last().Items[0] = (string)verses.Last().Items[0] + " " + line; continue; } if (latestChapter == null || latestBook == null || verse.Chapter.ToString() != latestChapter.cnumber || verse.BookIndex != latestBook.Index) { if (latestBook == null || verse.BookIndex != latestBook.Index) { if (latestBook != null) { latestBook.Items = chapters.ToArray(); } latestBook = new BIBLEBOOK() { bnumber = verse.BookIndex.ToString() }; books.Add(latestBook); chapters = new List <CHAPTER>(); } if (latestChapter != null) { latestChapter.Items = verses.ToArray(); } latestChapter = new CHAPTER() { cnumber = verse.Chapter.ToString() }; chapters.Add(latestChapter); verses = new List <VERS>(); } verses.Add(new VERS() { vnumber = verse.Verse.ToString(), Items = new string[] { verseText } }); } catch (InvalidProgramException) { } } latestBook.Items = chapters.ToArray(); latestChapter.Items = verses.ToArray(); var bible = new XMLBIBLE() { BIBLEBOOK = books.ToArray() }; XmlUtils.SaveToXmlFile(bible, Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + ".xml")); }
public void ReloadInfo() { CurrentModuleInfo = _modulesManager.GetCurrentModuleInfo(); _biblesContent = new Dictionary <string, XMLBIBLE>(); _currentBibleContent = null; }