コード例 #1
0
        private static async Task <EpubContent> ReadContent(EpubContentRef contentRef)
        {
            EpubContent result = new EpubContent();

            result.Html = await ReadTextContentFiles(contentRef.Html).ConfigureAwait(false);

            result.Css = await ReadTextContentFiles(contentRef.Css).ConfigureAwait(false);

            result.Images = await ReadByteContentFiles(contentRef.Images).ConfigureAwait(false);

            result.Fonts = await ReadByteContentFiles(contentRef.Fonts).ConfigureAwait(false);

            result.AllFiles = new Dictionary <string, EpubContentFile>();
            foreach (KeyValuePair <string, EpubTextContentFile> textContentFile in result.Html.Concat(result.Css))
            {
                result.AllFiles.Add(textContentFile.Key, textContentFile.Value);
            }
            foreach (KeyValuePair <string, EpubByteContentFile> byteContentFile in result.Images.Concat(result.Fonts))
            {
                result.AllFiles.Add(byteContentFile.Key, byteContentFile.Value);
            }
            foreach (KeyValuePair <string, EpubContentFileRef> contentFileRef in contentRef.AllFiles)
            {
                if (!result.AllFiles.ContainsKey(contentFileRef.Key))
                {
                    result.AllFiles.Add(contentFileRef.Key, await ReadByteContentFile(contentFileRef.Value).ConfigureAwait(false));
                }
            }
            if (contentRef.Cover != null)
            {
                result.Cover = result.Images[contentRef.Cover.FileName];
            }
            return(result);
        }
コード例 #2
0
ファイル: EpubReader.cs プロジェクト: yodelife/QuickLook
        private static async Task <EpubContent> ReadContent(EpubContentRef contentRef)
        {
            var result = new EpubContent();

            result.Html = await ReadTextContentFiles(contentRef.Html).ConfigureAwait(false);

            result.Css = await ReadTextContentFiles(contentRef.Css).ConfigureAwait(false);

            result.Images = await ReadByteContentFiles(contentRef.Images).ConfigureAwait(false);

            result.Fonts = await ReadByteContentFiles(contentRef.Fonts).ConfigureAwait(false);

            result.AllFiles = new Dictionary <string, EpubContentFile>();
            foreach (var textContentFile in result.Html.Concat(result.Css))
            {
                result.AllFiles.Add(textContentFile.Key, textContentFile.Value);
            }
            foreach (var byteContentFile in result.Images.Concat(result.Fonts))
            {
                result.AllFiles.Add(byteContentFile.Key, byteContentFile.Value);
            }
            foreach (var contentFileRef in contentRef.AllFiles)
            {
                if (!result.AllFiles.ContainsKey(contentFileRef.Key))
                {
                    result.AllFiles.Add(contentFileRef.Key,
                                        await ReadByteContentFile(contentFileRef.Value).ConfigureAwait(false));
                }
            }
            return(result);
        }