summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs
blob: de2190760efe92e30ad3d7b3fb9a2561d44c33e2 (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
using System.Linq;
using Newtonsoft.Json;
using StardewModdingAPI.Framework.Serialisation;

namespace StardewModdingAPI.Framework.Models
{
    /// <summary>Metadata about a mod from SMAPI's internal data.</summary>
    internal class ModDataRecord
    {
        /*********
        ** Accessors
        *********/
        /// <summary>The unique mod identifier.</summary>
        [JsonConverter(typeof(SFieldConverter))]
        public ModDataID ID { get; set; }

        /// <summary>The mod name.</summary>
        public string Name { get; set; }

        /// <summary>The URLs the user can check for a newer version.</summary>
        public string[] UpdateUrls { get; set; }

        /// <summary>The compatibility of given mod versions (if any).</summary>
        [JsonConverter(typeof(SFieldConverter))]
        public ModCompatibility[] Compatibility { get; set; } = new ModCompatibility[0];


        /*********
        ** Public methods
        *********/
        /// <summary>Get the compatibility record for a given version, if any.</summary>
        /// <param name="version">The mod version to check.</param>
        public ModCompatibility GetCompatibility(ISemanticVersion version)
        {
            return this.Compatibility.FirstOrDefault(p => p.MatchesVersion(version));
        }
    }
}