示例#1
0
 private void ProcessTitleData(TokenIndex top, XElement xelement, int bookLevel)
 {
     var item = new BookChapter
                    {
                        Level = bookLevel,
                        Title = GetText(xelement),
                        TokenID = top.Index
                    };
     _chapters.Add(item);
 }
示例#2
0
 private static ChapterModel CreateChapter(string bookId, BookChapter chapter, IList<TokenBase> tokens)
 {
     return new ChapterModel
         {
             BookID = bookId,
             Level = chapter.Level,
             Title = chapter.Title.Length > 1024 ? chapter.Title.Substring(0, 1024) : chapter.Title,
             TokenID = GetUIToken(chapter.TokenID, tokens),
             MinTokenID = GetMinToken(chapter.TokenID, tokens)
         };
 }
 private void ParseItems(XElement root, int level, XNamespace ns, EpubPath path)
 {
     foreach (XElement navPoint in root.Elements(ns + "navPoint"))
     {
         XElement text = navPoint.Elements(ns + "navLabel").Elements(ns + "text").FirstOrDefault();
         if (text == null)
             continue;
         
         XAttribute srcAttr = navPoint.Elements(ns + "content").Attributes("src").FirstOrDefault();
         if (srcAttr == null)
             continue;
                     
         string cleanSource = srcAttr.Value;
         int length = srcAttr.Value.IndexOf("#", StringComparison.Ordinal);
         length = length > -1 ? length : cleanSource.Length;
         cleanSource = cleanSource.Substring(0, length);
                         
         string key = path + cleanSource;
         if (Anchors.ContainsKey(key))
         {
             int num = Anchors[key];
             var item = new BookChapter
                         {
                             Level = level,
                             Title = CleanText(text.Value),
                             TokenID = num
                         };
             Chapters.Add(item);
             ParseItems(navPoint, level + 1, ns, path);
         }
     }
 }