diff options
Diffstat (limited to 'src/SMAPI.Web/ViewModels/ModCompatibilityModel.cs')
-rw-r--r-- | src/SMAPI.Web/ViewModels/ModCompatibilityModel.cs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/SMAPI.Web/ViewModels/ModCompatibilityModel.cs b/src/SMAPI.Web/ViewModels/ModCompatibilityModel.cs index 2af30cc3..36ea891d 100644 --- a/src/SMAPI.Web/ViewModels/ModCompatibilityModel.cs +++ b/src/SMAPI.Web/ViewModels/ModCompatibilityModel.cs @@ -1,5 +1,4 @@ -#nullable disable - +using Newtonsoft.Json; using StardewModdingAPI.Toolkit.Framework.Clients.Wiki; namespace StardewModdingAPI.Web.ViewModels @@ -11,22 +10,36 @@ namespace StardewModdingAPI.Web.ViewModels ** Accessors *********/ /// <summary>The compatibility status, as a string like <c>"Broken"</c>.</summary> - public string Status { get; set; } + public string Status { get; } /// <summary>The human-readable summary, as an HTML block.</summary> - public string Summary { get; set; } + public string? Summary { get; } /// <summary>The game or SMAPI version which broke this mod (if applicable).</summary> - public string BrokeIn { get; set; } + public string? BrokeIn { get; } /// <summary>A link to the unofficial version which fixes compatibility, if any.</summary> - public ModLinkModel UnofficialVersion { get; set; } + public ModLinkModel? UnofficialVersion { get; } /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> + /// <param name="status">The compatibility status, as a string like <c>"Broken"</c>.</param> + /// <param name="summary">The human-readable summary, as an HTML block.</param> + /// <param name="brokeIn">The game or SMAPI version which broke this mod (if applicable).</param> + /// <param name="unofficialVersion">A link to the unofficial version which fixes compatibility, if any.</param> + [JsonConstructor] + public ModCompatibilityModel(string status, string? summary, string? brokeIn, ModLinkModel? unofficialVersion) + { + this.Status = status; + this.Summary = summary; + this.BrokeIn = brokeIn; + this.UnofficialVersion = unofficialVersion; + } + + /// <summary>Construct an instance.</summary> /// <param name="info">The mod metadata.</param> public ModCompatibilityModel(WikiCompatibilityInfo info) { @@ -36,7 +49,7 @@ namespace StardewModdingAPI.Web.ViewModels this.Summary = info.Summary; this.BrokeIn = info.BrokeIn; if (info.UnofficialVersion != null) - this.UnofficialVersion = new ModLinkModel(info.UnofficialUrl, info.UnofficialVersion.ToString()); + this.UnofficialVersion = new ModLinkModel(info.UnofficialUrl!, info.UnofficialVersion.ToString()); } } } |