-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.cs
More file actions
52 lines (37 loc) · 1.38 KB
/
Input.cs
File metadata and controls
52 lines (37 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace ManagedCode.ClaudeCodeSharpSDK.Models;
public abstract record UserInput;
public sealed record TextInput(string Text) : UserInput;
public sealed record LocalImageInput : UserInput
{
private const string UnreadableImageStreamMessage = "Image stream must be readable.";
internal string? Path { get; }
internal FileInfo? File { get; }
internal Stream? Content { get; }
internal string? FileName { get; }
internal bool LeaveOpen { get; }
public LocalImageInput(string path)
{
ArgumentException.ThrowIfNullOrWhiteSpace(path);
Path = path;
}
public LocalImageInput(FileInfo file)
{
ArgumentNullException.ThrowIfNull(file);
File = file;
}
public LocalImageInput(Stream content, string? fileName = null, bool leaveOpen = false)
{
ArgumentNullException.ThrowIfNull(content);
if (!content.CanRead)
{
throw new ArgumentException(UnreadableImageStreamMessage, nameof(content));
}
Content = content;
FileName = fileName;
LeaveOpen = leaveOpen;
}
public static LocalImageInput FromPath(string path) => new(path);
public static LocalImageInput FromFile(FileInfo file) => new(file);
public static LocalImageInput FromStream(Stream content, string? fileName = null, bool leaveOpen = false)
=> new(content, fileName, leaveOpen);
}