Beispiel #1
0
 public EpubFileEntry(EpubFile file, string directoryName)
 {
     _directoryName = new DirectoryInfo(directoryName).FullName;
     _json          = Path.Combine(_directoryName, "epub.json");
     BookId         = file.BookId;
     DC             = file.DC ?? new DublinCore();
     Metadata       = file.Metadata ?? new Dictionary <string, string>();
     Manifest       = file.Manifest ?? new List <Manifest>();
 }
Beispiel #2
0
 public EpubFileEntry(EpubFile file, string directoryName)
 {
     _directoryName = directoryName;
     BookId         = file.BookId;
     CoverImage     = file.CoverImage;
     CoverFile      = file.CoverFile;
     DC             = file.DC;
     Metadata       = file.Metadata;
     Manifest       = file.Manifest;
 }
Beispiel #3
0
        /// <summary>
        /// 加载电子书解压后得物理文件夹。
        /// </summary>
        /// <param name="bookId">电子书Id。</param>
        /// <returns>返回电子书组成配置文件实例。</returns>
        public IEpubFile Create(string bookId)
        {
            var path     = GetEpubPath(bookId);
            var jsonPath = Path.Combine(path, "epub.json");

            if (File.Exists(jsonPath))
            {
                var file = Cores.FromJsonString <EpubFile>(StorageHelper.ReadText(jsonPath));
                if (file != null)
                {
                    return(new EpubFileEntry(file, path));
                }
            }
            var instance = new EpubFile {
                BookId = bookId
            };

            StorageHelper.SaveText(jsonPath, instance.ToJsonString());
            return(new EpubFileEntry(instance, path));
        }