namespace AIStudio.Chat;
public static class SetFileAttachmentExtensions
{
///
/// Attaches a file in place of the attachment of the same file the set held before.
///
///
/// The attachments differ by more than their files: one of a message being edited holds the
/// entry of the text it was sent with, and the size of the file may have changed since. Both
/// would stay in the set, and the message would go with the old and the new text of the file.
/// Attaching a file again means the file as it is now.
///
/// The attachments of a message.
/// The attachment of the file just attached.
public static void AttachInPlaceOfSameFile(this HashSet attachments, FileAttachment attachment)
{
attachments.RemoveWhere(existing => string.Equals(existing.FilePath, attachment.FilePath, StringComparison.Ordinal));
attachments.Add(attachment);
}
}