summaryrefslogtreecommitdiff
path: root/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs
blob: f7dc8aa806791ea5b55e5624f1b6fb540477b4ee (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
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>
#if NET5_0_OR_GREATER
        [return: NotNullIfNotNull("input")]
#endif
        private string? NormalizeWhitespace(string? input)
        {
            return input?.Trim();
        }
    }
}