コード例 #1
0
        public int GetBibleChaptersCount(XMLBIBLE bibleInfo, bool addBooksCount)
        {
            int result = bibleInfo.Books.Sum(b => b.Chapters.Count);

            if (addBooksCount)
            {
                result += bibleInfo.Books.Count;
            }

            return(result);
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
 public void ReloadInfo()
 {
     CurrentModuleInfo    = _modulesManager.GetCurrentModuleInfo();
     _biblesContent       = new Dictionary <string, XMLBIBLE>();
     _currentBibleContent = null;
 }