diff options
Diffstat (limited to 'src/SMAPI.Web/Framework/Clients/Pastebin/PasteInfo.cs')
-rw-r--r-- | src/SMAPI.Web/Framework/Clients/Pastebin/PasteInfo.cs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/SMAPI.Web/Framework/Clients/Pastebin/PasteInfo.cs b/src/SMAPI.Web/Framework/Clients/Pastebin/PasteInfo.cs index 2d48a7ae..7f40e713 100644 --- a/src/SMAPI.Web/Framework/Clients/Pastebin/PasteInfo.cs +++ b/src/SMAPI.Web/Framework/Clients/Pastebin/PasteInfo.cs @@ -1,17 +1,35 @@ -#nullable disable +using System.Diagnostics.CodeAnalysis; namespace StardewModdingAPI.Web.Framework.Clients.Pastebin { /// <summary>The response for a get-paste request.</summary> internal class PasteInfo { + /********* + ** Accessors + *********/ /// <summary>Whether the log was successfully fetched.</summary> - public bool Success { get; set; } + [MemberNotNullWhen(true, nameof(PasteInfo.Content))] + [MemberNotNullWhen(false, nameof(PasteInfo.Error))] + public bool Success => this.Error == null || this.Content != null; /// <summary>The fetched paste content (if <see cref="Success"/> is <c>true</c>).</summary> - public string Content { get; set; } + public string? Content { get; internal set; } - /// <summary>The error message if saving failed.</summary> - public string Error { get; set; } + /// <summary>The error message (if <see cref="Success"/> is <c>false</c>).</summary> + public string? Error { get; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="content">The fetched paste content.</param> + /// <param name="error">The error message, if it failed.</param> + public PasteInfo(string? content, string? error) + { + this.Content = content; + this.Error = error; + } } } |