コード例 #1
0
        private MetadataResult <Book>?ReadEpubAsZip(string path, CancellationToken cancellationToken)
        {
            using var epub = ZipFile.OpenRead(path);

            var opfFilePath = EpubUtils.ReadContentFilePath(epub);

            if (opfFilePath == null)
            {
                return(null);
            }

            var opf = epub.GetEntry(opfFilePath);

            if (opf == null)
            {
                return(null);
            }

            using var opfStream = opf.Open();

            var opfDocument = new XmlDocument();

            opfDocument.Load(opfStream);

            var utilities = new OpfReader <EpubMetadataProvider>(opfDocument, _logger);

            return(utilities.ReadOpfData(cancellationToken));
        }
コード例 #2
0
        private void ReadEpubAsZip(MetadataResult <Book> result, string path, CancellationToken cancellationToken)
        {
            using var epub = ZipFile.OpenRead(path);

            var opfFilePath = EpubUtils.ReadContentFilePath(epub);

            if (opfFilePath == null)
            {
                return;
            }

            var opf = epub.GetEntry(opfFilePath);

            if (opf == null)
            {
                return;
            }

            using var opfStream = opf.Open();

            var opfDocument = new XmlDocument();

            opfDocument.Load(opfStream);

            OpfReader.ReadOpfData(result, opfDocument, cancellationToken, _logger);
        }