mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 20:01:37 +00:00
Enhance FileAttachment properties for clarity and performance by using read-only auto-properties and adding IsImage check
This commit is contained in:
parent
ddb1677bc5
commit
a75be1163b
@ -11,20 +11,37 @@ namespace AIStudio.Chat;
|
||||
/// <param name="FileSizeBytes">The size of the file in bytes.</param>
|
||||
public readonly record struct FileAttachment(FileAttachmentType Type, string FileName, string FilePath, long FileSizeBytes)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the file still exists on the file system.
|
||||
/// </summary>
|
||||
public bool Exists => File.Exists(this.FilePath);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the file type is forbidden and should not be attached.
|
||||
/// </summary>
|
||||
public bool IsForbidden => this.Type == FileAttachmentType.FORBIDDEN;
|
||||
/// <remarks>
|
||||
/// The state is determined once during construction and does not change.
|
||||
/// </remarks>
|
||||
public bool IsForbidden { get; } = Type == FileAttachmentType.FORBIDDEN;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the file type is valid and allowed to be attached.
|
||||
/// </summary>
|
||||
public bool IsValid => this.Type != FileAttachmentType.FORBIDDEN;
|
||||
/// <remarks>
|
||||
/// The state is determined once during construction and does not change.
|
||||
/// </remarks>
|
||||
public bool IsValid { get; } = Type != FileAttachmentType.FORBIDDEN;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the file type is an image.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The state is determined once during construction and does not change.
|
||||
/// </remarks>
|
||||
public bool IsImage { get; } = Type == FileAttachmentType.IMAGE;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the file still exists on the file system.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property checks the file system each time it is accessed.
|
||||
/// </remarks>
|
||||
public bool Exists => File.Exists(this.FilePath);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a FileAttachment from a file path by automatically determining the type,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user