Refactor: Rename DocumentOperator to DocumentService
Updated project and solution files to rename and restructure `DocumentOperator` to `DocumentService`. Modified project references in `DocumentService.API.csproj`, `DocumentService.Application.csproj`, and `DocumentService.Infrastructure.csproj` to reflect the new naming convention. Updated `DocumentService.sln` to remove old project references, add new ones, and adjust configuration and nested project mappings accordingly. This change aligns the project structure with the new naming convention.
This commit is contained in:
60
DocumentService.Application/Common/DTOs/AttachmentInfo.cs
Normal file
60
DocumentService.Application/Common/DTOs/AttachmentInfo.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
namespace DocumentService.Application.Common.DTOs;
|
||||
|
||||
/// <summary>
|
||||
/// Represents complete attachment information for a PDF document.
|
||||
/// Immutable value object containing attachment presence flag, count, and detailed metadata.
|
||||
/// </summary>
|
||||
public sealed class AttachmentInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the PDF contains any attachments
|
||||
/// </summary>
|
||||
public bool HasAttachments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of attachments in the PDF
|
||||
/// </summary>
|
||||
public int AttachmentCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of attachment metadata (file details)
|
||||
/// </summary>
|
||||
public IReadOnlyList<AttachmentMetadata> Attachments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AttachmentInfo class.
|
||||
/// </summary>
|
||||
/// <param name="hasAttachments">Whether PDF has attachments</param>
|
||||
/// <param name="attachmentCount">Total number of attachments</param>
|
||||
/// <param name="attachments">List of attachment metadata (can be empty)</param>
|
||||
public AttachmentInfo(bool hasAttachments, int attachmentCount, IReadOnlyList<AttachmentMetadata> 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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an AttachmentInfo instance for a PDF with no attachments.
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user