blob: bbbcf2a9549c3dfdad058c7faf4f6b208d967fff (
plain)
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
|
using System;
using System.Diagnostics.CodeAnalysis;
namespace StardewModdingAPI.Web.Framework.Storage
{
/// <summary>The response for a get-file request.</summary>
internal class StoredFileInfo
{
/*********
** Accessors
*********/
/// <summary>Whether the file was successfully fetched.</summary>
[MemberNotNullWhen(true, nameof(StoredFileInfo.Content))]
public bool Success => this.Content != null && this.Error == null;
/// <summary>The fetched file content (if <see cref="Success"/> is <c>true</c>).</summary>
public string? Content { get; }
/// <summary>When the file will no longer be available.</summary>
public DateTimeOffset? Expiry { get; }
/// <summary>The error message if saving succeeded, but a non-blocking issue was encountered.</summary>
public string? Warning { get; }
/// <summary>The error message if saving failed.</summary>
public string? Error { get; }
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="content">The fetched file content (if <see cref="Success"/> is <c>true</c>).</param>
/// <param name="expiry">When the file will no longer be available.</param>
/// <param name="warning">The error message if saving succeeded, but a non-blocking issue was encountered.</param>
/// <param name="error">The error message if saving failed.</param>
public StoredFileInfo(string? content, DateTimeOffset? expiry, string? warning = null, string? error = null)
{
this.Content = content;
this.Expiry = expiry;
this.Warning = warning;
this.Error = error;
}
/// <summary>Construct an instance.</summary>
/// <param name="error">The error message if saving failed.</param>
public StoredFileInfo(string error)
{
this.Error = error;
}
}
}
|