File size: 3,245 Bytes
fab29d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.IO;

namespace VersOne.Epub.Options
{
    /// <summary>
    /// Provides data for the <see cref="ContentReaderOptions.ContentFileMissing" /> event.
    /// </summary>
    public class ContentFileMissingEventArgs : EventArgs
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ContentFileMissingEventArgs" /> class with a specified file name, an absolute file path, a content type of the file,
        /// and a MIME type of the file's content.
        /// </summary>
        /// <param name="fileKey">Relative file path of the missing content file (as it is specified in the EPUB manifest).</param>
        /// <param name="filePath">Absolute file path of the missing content file in the EPUB archive.</param>
        /// <param name="contentType">The type of the content of the missing file.</param>
        /// <param name="contentMimeType">The MIME type of the content of the missing file.</param>
        public ContentFileMissingEventArgs(string fileKey, string filePath, EpubContentType contentType, string contentMimeType)
        {
            FileKey = fileKey;
            FilePath = filePath;
            ContentType = contentType;
            ContentMimeType = contentMimeType;
            SuppressException = false;
            ReplacementContentStream = null;
        }

        /// <summary>
        /// Gets the relative file path of the missing content file (as it is specified in the EPUB manifest).
        /// </summary>
        public string FileKey { get; }

        /// <summary>
        /// Gets the absolute file path of the missing content file in the EPUB archive.
        /// </summary>
        public string FilePath { get; }

        /// <summary>
        /// Gets the type of the content of the missing file.
        /// </summary>
        public EpubContentType ContentType { get; }

        /// <summary>
        /// Gets the MIME type of the content of the missing file.
        /// </summary>
        public string ContentMimeType { get; }

        /// <summary>
        /// Gets or sets a value indicating whether the EPUB content reader should suppress the exception for the missing file. If it is set to <c>true</c>
        /// and the replacement content stream is not provided (via the <see cref="ReplacementContentStream" /> property), then the EPUB content reader will treat
        /// the missing file as an existing but empty file.
        /// Default value is <c>false</c>.
        /// </summary>
        public bool SuppressException { get; set; }

        /// <summary>
        /// Gets or sets the replacement content stream. This property allows the application to provide a replacement content for the missing file in the form of
        /// a <see cref="Stream" />. When the content stream is provided, the EPUB content reader will not throw an exception for the missing file,
        /// regardless of the value of the <see cref="SuppressException" /> property. The content of the stream is read only once, after which it will be cached
        /// in the EPUB content reader. The stream will be closed after its content is fully read.
        /// </summary>
        public Stream? ReplacementContentStream { get; set; }
    }
}