- Move PdfMetadata, PdfAMetadata from Domain.Models.ValueObjects to Application.Common.DTOs - Move AttachmentInfo, AttachmentMetadata from Domain.Models.ValueObjects to Application.Common.DTOs - Reason: DTOs belong in Application layer, Domain should have zero external dependencies (Clean Architecture)
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
namespace DocumentOperator.Application.Common.DTOs;
|
|
|
|
/// <summary>
|
|
/// Represents metadata of a single PDF attachment (embedded file).
|
|
/// Immutable value object containing file information without the actual binary data.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Initializes a new instance of the AttachmentMetadata class.
|
|
/// </remarks>
|
|
/// <param name="fileName">Attachment file name</param>
|
|
/// <param name="mimeType">MIME type (e.g., "text/xml")</param>
|
|
/// <param name="sizeBytes">File size in bytes</param>
|
|
public sealed class AttachmentMetadata(string fileName, string mimeType, long sizeBytes)
|
|
{
|
|
/// <summary>
|
|
/// Gets the attachment file name (e.g., "invoice.xml", "document.pdf")
|
|
/// </summary>
|
|
public string FileName { get; } = fileName ?? string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets the MIME type of the attachment (e.g., "text/xml", "application/pdf")
|
|
/// </summary>
|
|
public string MimeType { get; } = mimeType ?? "application/octet-stream"; // Default MIME type if unknown
|
|
|
|
/// <summary>
|
|
/// Gets the attachment file size in bytes
|
|
/// </summary>
|
|
public long SizeBytes { get; } = sizeBytes;
|
|
|
|
/// <summary>
|
|
/// Gets the attachment file size in kilobytes (computed property)
|
|
/// </summary>
|
|
public double SizeKB => SizeBytes / 1024.0;
|
|
|
|
/// <summary>
|
|
/// Gets the attachment file size in megabytes (computed property)
|
|
/// </summary>
|
|
public double SizeMB => SizeBytes / 1024.0 / 1024.0;
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{FileName} ({MimeType}, {SizeKB:F2} KB)";
|
|
}
|
|
}
|