using System; using System.IO; using System.Reflection; using JetBrains.Annotations; namespace Abp.Resources.Embedded { /// /// Stores needed information of an embedded resource. /// public class EmbeddedResourceItem { /// /// File name including extension. /// public string FileName { get; } [CanBeNull] public string FileExtension { get; } /// /// Content of the resource file. /// public byte[] Content { get; set; } /// /// The assembly that contains the resource. /// public Assembly Assembly { get; set; } public DateTime LastModifiedUtc { get; } internal EmbeddedResourceItem(string fileName, byte[] content, Assembly assembly) { FileName = fileName; Content = content; Assembly = assembly; FileExtension = CalculateFileExtension(FileName); LastModifiedUtc = Assembly.Location != null ? new FileInfo(Assembly.Location).LastWriteTimeUtc : DateTime.UtcNow; } private static string CalculateFileExtension(string fileName) { if (!fileName.Contains(".")) { return null; } return fileName.Substring(fileName.LastIndexOf(".", StringComparison.Ordinal) + 1); } } }