private static List <EpubNavigationItem> ReadNavigation(EpubBook epubBook, List <EpubNavigationItemRef> navigationItemRefs) { List <EpubNavigationItem> result = new List <EpubNavigationItem>(); foreach (EpubNavigationItemRef navigationItemRef in navigationItemRefs) { EpubNavigationItem navigationItem = new EpubNavigationItem(navigationItemRef.Type) { Title = navigationItemRef.Title, Link = navigationItemRef.Link, }; if (navigationItemRef.HtmlContentFileRef != null) { navigationItem.HtmlContentFile = epubBook.Content.Html[navigationItemRef.HtmlContentFileRef.FileName]; } navigationItem.NestedItems = ReadNavigation(epubBook, navigationItemRef.NestedItems); result.Add(navigationItem); } return(result); }
private static async Task <EpubBook> ReadBookAsync(EpubBookRef epubBookRef) { EpubBook result = new EpubBook(); using (epubBookRef) { result.FilePath = epubBookRef.FilePath; result.Schema = epubBookRef.Schema; result.Title = epubBookRef.Title; result.AuthorList = epubBookRef.AuthorList; result.Author = epubBookRef.Author; result.Content = await ReadContent(epubBookRef.Content).ConfigureAwait(false); result.CoverImage = await epubBookRef.ReadCoverAsync().ConfigureAwait(false); List <EpubTextContentFileRef> htmlContentFileRefs = await epubBookRef.GetReadingOrderAsync().ConfigureAwait(false); result.ReadingOrder = ReadReadingOrder(result, htmlContentFileRefs); List <EpubNavigationItemRef> navigationItemRefs = await epubBookRef.GetNavigationAsync().ConfigureAwait(false); result.Navigation = ReadNavigation(result, navigationItemRefs); } return(result); }
private static List <EpubTextContentFile> ReadReadingOrder(EpubBook epubBook, List <EpubTextContentFileRef> htmlContentFileRefs) { return(htmlContentFileRefs.Select(htmlContentFileRef => epubBook.Content.Html[htmlContentFileRef.FileName]).ToList()); }