using System; namespace EmbedIO.Files { /// /// Contains information about a resource served via an . /// public sealed class MappedResourceInfo { private MappedResourceInfo(string path, string name, DateTime lastModifiedUtc, long length, string? contentType) { Path = path; Name = name; LastModifiedUtc = lastModifiedUtc; Length = length; ContentType = contentType; } /// /// Gets a value indicating whether this instance represents a directory. /// public bool IsDirectory => ContentType == null; /// /// Gets a value indicating whether this instance represents a file. /// public bool IsFile => ContentType != null; /// /// Gets a unique, provider-specific path for the resource. /// public string Path { get; } /// /// Gets the name of the resource, as it would appear in a directory listing. /// public string Name { get; } /// /// Gets the UTC date and time of the last modification made to the resource. /// public DateTime LastModifiedUtc { get; } /// /// If is , gets the length of the file, expressed in bytes. /// If is , this property is always zero. /// public long Length { get; } /// /// If is , gets a MIME type describing the kind of contents of the file. /// If is , this property is always . /// public string? ContentType { get; } /// /// Creates and returns a new instance of the class, /// representing a file. /// /// A unique, provider-specific path for the file. /// The name of the file, as it would appear in a directory listing. /// The UTC date and time of the last modification made to the file. /// The length of the file, expressed in bytes. /// A MIME type describing the kind of contents of the file. /// A newly-constructed instance of . public static MappedResourceInfo ForFile(string path, string name, DateTime lastModifiedUtc, long size, string contentType) => new MappedResourceInfo(path, name, lastModifiedUtc, size, contentType ?? MimeType.Default); /// /// Creates and returns a new instance of the class, /// representing a directory. /// /// A unique, provider-specific path for the directory. /// The name of the directory, as it would appear in a directory listing. /// The UTC date and time of the last modification made to the directory. /// A newly-constructed instance of . public static MappedResourceInfo ForDirectory(string path, string name, DateTime lastModifiedUtc) => new MappedResourceInfo(path, name, lastModifiedUtc, 0, null); } }