Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        private static async Task <EpubBookRef> OpenBookAsync(ZipArchive zipArchive, string filePath = null)
        {
            EpubBookRef result = null;

            try
            {
                result = new EpubBookRef(zipArchive)
                {
                    FilePath = filePath,
                    Schema   = await SchemaReader.ReadSchemaAsync(zipArchive).ConfigureAwait(false)
                };
                result.Title      = result.Schema.Package.Metadata.Titles.FirstOrDefault() ?? String.Empty;
                result.AuthorList = result.Schema.Package.Metadata.Creators.Select(creator => creator.Creator).ToList();
                result.Author     = String.Join(", ", result.AuthorList);
                result.Content    = await Task.Run(() => ContentReader.ParseContentMap(result)).ConfigureAwait(false);

                return(result);
            }
            catch
            {
                result?.Dispose();
                throw;
            }
        }
Esempio n. 3
0
 public EpubByteContentFileRef(EpubBookRef epubBookRef)
     : base(epubBookRef)
 {
 }
Esempio n. 4
0
        /// <summary>
        /// Opens the book asynchronously and reads all of its content into the memory. Does not hold the handle to the EPUB file.
        /// </summary>
        /// <param name="filePath">path to the EPUB file</param>
        /// <returns></returns>
        public static async Task <EpubBook> ReadBookAsync(string filePath)
        {
            EpubBookRef epubBookRef = await OpenBookAsync(filePath).ConfigureAwait(false);

            return(await ReadBookAsync(epubBookRef).ConfigureAwait(false));
        }
Esempio n. 5
0
        /// <summary>
        /// Opens the book asynchronously and reads all of its content into the memory.
        /// </summary>
        /// <param name="stream">seekable stream containing the EPUB file</param>
        /// <returns></returns>
        public static async Task <EpubBook> ReadBookAsync(Stream stream)
        {
            EpubBookRef epubBookRef = await OpenBookAsync(stream).ConfigureAwait(false);

            return(await ReadBookAsync(epubBookRef).ConfigureAwait(false));
        }
 public EpubTextContentFileRef(EpubBookRef epubBookRef)
     : base(epubBookRef)
 {
 }
Esempio n. 7
0
 public EpubContentFileRef(EpubBookRef epubBookRef)
 {
     this.epubBookRef = epubBookRef;
 }