summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-12 19:15:39 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-12 19:15:39 -0400
commit0b48c1748b354458059c7607415288de072b01e9 (patch)
treef63fd950f565d363414eb692be9024895cdea174 /src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs
parent9fbed0fa1f28a9b0fe0b952a78b10e2d475adb03 (diff)
downloadSMAPI-0b48c1748b354458059c7607415288de072b01e9.tar.gz
SMAPI-0b48c1748b354458059c7607415288de072b01e9.tar.bz2
SMAPI-0b48c1748b354458059c7607415288de072b01e9.zip
enable nullable annotations in the web project & related code (#837)
Diffstat (limited to 'src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs')
-rw-r--r--src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs b/src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs
index cd941c94..bbbcf2a9 100644
--- a/src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs
+++ b/src/SMAPI.Web/Framework/Storage/StoredFileInfo.cs
@@ -1,25 +1,52 @@
-#nullable disable
-
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>
- public bool Success { get; set; }
+ [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; set; }
+ public string? Content { get; }
/// <summary>When the file will no longer be available.</summary>
- public DateTime? Expiry { get; set; }
+ public DateTimeOffset? Expiry { get; }
/// <summary>The error message if saving succeeded, but a non-blocking issue was encountered.</summary>
- public string Warning { get; set; }
+ public string? Warning { get; }
/// <summary>The error message if saving failed.</summary>
- public string Error { get; set; }
+ 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;
+ }
}
}