namespace DocumentService.Application.Common.DTOs;
///
/// Represents complete attachment information for a PDF document.
/// Immutable value object containing attachment presence flag, count, and detailed metadata.
///
public sealed class AttachmentInfo
{
///
/// Gets a value indicating whether the PDF contains any attachments
///
public bool HasAttachments { get; }
///
/// Gets the total number of attachments in the PDF
///
public int AttachmentCount { get; }
///
/// Gets the collection of attachment metadata (file details)
///
public IReadOnlyList Attachments { get; }
///
/// Initializes a new instance of the AttachmentInfo class.
///
/// Whether PDF has attachments
/// Total number of attachments
/// List of attachment metadata (can be empty)
public AttachmentInfo(bool hasAttachments, int attachmentCount, IReadOnlyList attachments)
{
HasAttachments = hasAttachments;
AttachmentCount = attachmentCount;
Attachments = attachments ?? [];
// Defensive Programming: Ensure count matches list length
if (Attachments.Count != attachmentCount)
{
throw new ArgumentException(
$"Attachment count mismatch: expected {attachmentCount}, got {Attachments.Count}",
nameof(attachments));
}
}
///
/// Creates an AttachmentInfo instance for a PDF with no attachments.
///
public static AttachmentInfo Empty =>
new(
hasAttachments: false,
attachmentCount: 0,
attachments: []);
public override string ToString()
{
return HasAttachments
? $"PDF has {AttachmentCount} attachment(s): {string.Join(", ", Attachments.Select(a => a.FileName))}"
: "PDF has no attachments";
}
}