Ejemplo n.º 1
0
        public bool TryRead(out Epub epub)
        {
            bool result;

            try
            {
                epub   = this.Read();
                result = true;
            }
            catch (Exception)
            {
                epub   = null;
                result = false;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public Epub Read()
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException("archive");
            }

            var structure = this.ReadStructure();
            var metadata  = structure.Package.Metadata;
            var result    = new Epub
            {
                Structure   = structure,
                Contributor = String.Join(SEPARATOR, metadata.Contributors.Select(p => p.Value)),
                Coverage    = String.Join(SEPARATOR, metadata.Coverages.Select(p => p.Value)),
                Creator     = String.Join(SEPARATOR, metadata.Creators.Select(p => p.Value)),
                Date        = metadata.Date?.Value,
                Description = String.Join(SEPARATOR, metadata.Descriptions.Select(p => p.Value)),
                Format      = String.Join(SEPARATOR, metadata.Formats.Select(p => p.Value)),
                Identifier  = String.Join(SEPARATOR, metadata.Identifiers.Select(p => p.Value)),
                Language    = String.Join(SEPARATOR, metadata.Languages.Select(p => p.Value)),
                Publisher   = String.Join(SEPARATOR, metadata.Publishers.Select(p => p.Value)),
                Relation    = String.Join(SEPARATOR, metadata.Relations.Select(p => p.Value)),
                Rights      = String.Join(SEPARATOR, metadata.Rights.Select(p => p.Value)),
                Source      = String.Join(SEPARATOR, metadata.Sources.Select(p => p.Value)),
                Subject     = String.Join(SEPARATOR, metadata.Subjects.Select(p => p.Value)),
                Title       = String.Join(SEPARATOR, metadata.Titles.Select(p => p.Value)),
                Type        = String.Join(SEPARATOR, metadata.Types.Select(p => p.Value)),
            };

            var opfDirectory = Path.GetDirectoryName(structure.Container.FullPath);

            result.Cover = FindCoverFile(structure.Package, opfDirectory);
            FillChapters(result.Chapters, structure, opfDirectory);
            FillReadingFiles(result.ReadingFiles, structure.Package, opfDirectory);
            FillAllFiles(result.AllFiles, structure.Package, opfDirectory);

            return(result);
        }