summaryrefslogtreecommitdiff
path: root/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs
blob: dcdbcf74dace4fc8687fce32f2e6a1ddcb0aa331 (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
using System.Diagnostics.CodeAnalysis;

namespace StardewModdingAPI.Toolkit.Serialization.Models
{
    /// <summary>Indicates which mod can read the content pack represented by the containing manifest.</summary>
    public class ManifestContentPackFor : IManifestContentPackFor
    {
        /*********
        ** Accessors
        *********/
        /// <summary>The unique ID of the mod which can read this content pack.</summary>
        public string UniqueID { get; }

        /// <summary>The minimum required version (if any).</summary>
        public ISemanticVersion? MinimumVersion { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="uniqueId">The unique ID of the mod which can read this content pack.</param>
        /// <param name="minimumVersion">The minimum required version (if any).</param>
        public ManifestContentPackFor(string uniqueId, ISemanticVersion? minimumVersion)
        {
            this.UniqueID = this.NormalizeWhitespace(uniqueId);
            this.MinimumVersion = minimumVersion;
        }


        /*********
        ** Private methods
        *********/
        /// <summary>Normalize whitespace in a raw string.</summary>
        /// <param name="input">The input to strip.</param>
        [return: NotNullIfNotNull("input")]
        private string? NormalizeWhitespace(string? input)
        {
            return input?.Trim();
        }
    }
}