summaryrefslogtreecommitdiff
path: root/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs
blob: 8fe8fa2ae60f8fcd1d42e4551a19bddb44b1114a (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
#nullable disable

using System;

namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
{
    /// <summary>Specifies the identifiers for a mod to match.</summary>
    public class ModSearchEntryModel
    {
        /*********
        ** Accessors
        *********/
        /// <summary>The unique mod ID.</summary>
        public string ID { get; set; }

        /// <summary>The namespaced mod update keys (if available).</summary>
        public string[] UpdateKeys { get; set; }

        /// <summary>The mod version installed by the local player. This is used for version mapping in some cases.</summary>
        public ISemanticVersion InstalledVersion { get; set; }

        /// <summary>Whether the installed version is broken or could not be loaded.</summary>
        public bool IsBroken { get; set; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an empty instance.</summary>
        public ModSearchEntryModel()
        {
            // needed for JSON deserializing
        }

        /// <summary>Construct an instance.</summary>
        /// <param name="id">The unique mod ID.</param>
        /// <param name="installedVersion">The version installed by the local player. This is used for version mapping in some cases.</param>
        /// <param name="updateKeys">The namespaced mod update keys (if available).</param>
        /// <param name="isBroken">Whether the installed version is broken or could not be loaded.</param>
        public ModSearchEntryModel(string id, ISemanticVersion installedVersion, string[] updateKeys, bool isBroken = false)
        {
            this.ID = id;
            this.InstalledVersion = installedVersion;
            this.UpdateKeys = updateKeys ?? Array.Empty<string>();
        }
    }
}