using System; using VersOne.Epub.Schema; namespace VersOne.Epub { /// /// The base class for content file references. /// public abstract class EpubContentFileRef { private readonly EpubContentFileRefMetadata metadata; private readonly IEpubContentLoader epubContentLoader; /// /// Initializes a new instance of the class with a specified metadata and a specified content loader. /// /// Metadata of this content file reference. /// A reference to the EPUB content loader which provides methods to load the content of this file. /// The parameter is null. /// The parameter is null. protected EpubContentFileRef(EpubContentFileRefMetadata metadata, IEpubContentLoader epubContentLoader) { this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata)); this.epubContentLoader = epubContentLoader ?? throw new ArgumentNullException(nameof(epubContentLoader)); } /// /// Gets the content file reference key as it is declared in the EPUB manifest (in the property). /// This is either a relative path of the content file within the EPUB archive (for local content file references) /// or an absolute URI of the content file outside of the EPUB archive (for remote content file references). /// public string Key => metadata.Key; /// /// Gets the type of the content of the file (e.g. or ). /// public EpubContentType ContentType => metadata.ContentType; /// /// Gets the MIME type of the content of the file. /// public string ContentMimeType => metadata.ContentMimeType; /// /// Gets the location of the content file (local or remote). /// public abstract EpubContentLocation ContentLocation { get; } /// /// Gets the type of the content file reference (text or byte array). /// public abstract EpubContentFileType ContentFileType { get; } /// /// Gets the metadata of this content file reference. /// protected EpubContentFileRefMetadata Metadata => metadata; /// /// Gets the reference to the EPUB content loader which provides methods to load the content of this file. /// protected IEpubContentLoader EpubContentLoader => epubContentLoader; } }