summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Storage/UploadResult.cs
blob: 92993d42e6fa446bb0697301a62d44df922008dc (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
using System.Diagnostics.CodeAnalysis;

namespace StardewModdingAPI.Web.Framework.Storage
{
    /// <summary>The result of an attempt to upload a file.</summary>
    internal class UploadResult
    {
        /*********
        ** Accessors
        *********/
        /// <summary>Whether the file upload succeeded.</summary>
        [MemberNotNullWhen(true, nameof(UploadResult.ID))]
        [MemberNotNullWhen(false, nameof(UploadResult.UploadError))]
        public bool Succeeded => this.ID != null && this.UploadError == null;

        /// <summary>The file ID, if applicable.</summary>
        public string? ID { get; }

        /// <summary>The upload error, if any.</summary>
        public string? UploadError { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="id">The file ID, if applicable.</param>
        /// <param name="uploadError">The upload error, if any.</param>
        public UploadResult(string? id, string? uploadError)
        {
            this.ID = id;
            this.UploadError = uploadError;
        }
    }
}