File size: 2,513 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 |
using System;
using VersOne.Epub.Schema;
namespace VersOne.Epub
{
/// <summary>
/// Metadata for a content file reference.
/// </summary>
public class EpubContentFileRefMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="EpubContentFileRefMetadata" /> class with a specified content file key, a content type of the file reference,
/// and a MIME type of the file's content.
/// </summary>
/// <param name="key">The key of the content file as it is declared in the EPUB manifest (in the <see cref="EpubManifestItem.Href" /> property).</param>
/// <param name="contentType">The type of the content of the file.</param>
/// <param name="contentMimeType">The MIME type of the content of the file.</param>
/// <exception cref="ArgumentNullException">The <paramref name="key" /> parameter is <c>null</c>.</exception>
/// <exception cref="ArgumentException">The <paramref name="key" /> parameter is an empty string.</exception>
/// <exception cref="ArgumentNullException">The <paramref name="contentMimeType" /> parameter is <c>null</c>.</exception>
public EpubContentFileRefMetadata(string key, EpubContentType contentType, string contentMimeType)
{
Key = key ?? throw new ArgumentNullException(nameof(key));
if (key == String.Empty)
{
throw new ArgumentException("Content file name cannot be empty.", nameof(key));
}
ContentType = contentType;
ContentMimeType = contentMimeType ?? throw new ArgumentNullException(nameof(contentMimeType));
}
/// <summary>
/// Gets the content file key as it is declared in the EPUB manifest (in the <see cref="EpubManifestItem.Href" /> property).
/// This is either a relative path of the content file within the EPUB archive (for local content files)
/// or an absolute URI of the content file outside of the EPUB archive (for remote content files).
/// </summary>
public string Key { get; }
/// <summary>
/// Gets the type of the content of the file (e.g. <see cref="EpubContentType.XHTML_1_1" /> or <see cref="EpubContentType.IMAGE_JPEG" />).
/// </summary>
public EpubContentType ContentType { get; }
/// <summary>
/// Gets the MIME type of the content of the file.
/// </summary>
public string ContentMimeType { get; }
}
}
|