summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/ViewModels/ModModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/ViewModels/ModModel.cs')
-rw-r--r--src/SMAPI.Web/ViewModels/ModModel.cs65
1 files changed, 48 insertions, 17 deletions
diff --git a/src/SMAPI.Web/ViewModels/ModModel.cs b/src/SMAPI.Web/ViewModels/ModModel.cs
index d0d7373b..929bf682 100644
--- a/src/SMAPI.Web/ViewModels/ModModel.cs
+++ b/src/SMAPI.Web/ViewModels/ModModel.cs
@@ -1,7 +1,6 @@
-#nullable disable
-
using System.Collections.Generic;
using System.Linq;
+using Newtonsoft.Json;
using StardewModdingAPI.Toolkit.Framework.Clients.Wiki;
namespace StardewModdingAPI.Web.ViewModels
@@ -13,43 +12,43 @@ namespace StardewModdingAPI.Web.ViewModels
** Accessors
*********/
/// <summary>The mod name.</summary>
- public string Name { get; set; }
+ public string? Name { get; }
/// <summary>The mod's alternative names, if any.</summary>
- public string AlternateNames { get; set; }
+ public string AlternateNames { get; }
/// <summary>The mod author's name.</summary>
- public string Author { get; set; }
+ public string? Author { get; }
/// <summary>The mod author's alternative names, if any.</summary>
- public string AlternateAuthors { get; set; }
+ public string AlternateAuthors { get; }
/// <summary>The GitHub repo, if any.</summary>
- public string GitHubRepo { get; set; }
+ public string? GitHubRepo { get; }
/// <summary>The URL to the mod's source code, if any.</summary>
- public string SourceUrl { get; set; }
+ public string? SourceUrl { get; }
/// <summary>The compatibility status for the stable version of the game.</summary>
- public ModCompatibilityModel Compatibility { get; set; }
+ public ModCompatibilityModel Compatibility { get; }
/// <summary>The compatibility status for the beta version of the game.</summary>
- public ModCompatibilityModel BetaCompatibility { get; set; }
+ public ModCompatibilityModel? BetaCompatibility { get; }
/// <summary>Links to the available mod pages.</summary>
- public ModLinkModel[] ModPages { get; set; }
+ public ModLinkModel[] ModPages { get; }
/// <summary>The human-readable warnings for players about this mod.</summary>
- public string[] Warnings { get; set; }
+ public string[] Warnings { get; }
/// <summary>The URL of the pull request which submits changes for an unofficial update to the author, if any.</summary>
- public string PullRequestUrl { get; set; }
+ public string? PullRequestUrl { get; }
- /// <summary>Special notes intended for developers who maintain unofficial updates or submit pull requests. </summary>
- public string DevNote { get; set; }
+ /// <summary>Special notes intended for developers who maintain unofficial updates or submit pull requests.</summary>
+ public string? DevNote { get; }
/// <summary>A unique identifier for the mod that can be used in an anchor URL.</summary>
- public string Slug { get; set; }
+ public string? Slug { get; }
/// <summary>The sites where the mod can be downloaded.</summary>
public string[] ModPageSites => this.ModPages.Select(p => p.Text).ToArray();
@@ -59,6 +58,38 @@ namespace StardewModdingAPI.Web.ViewModels
** Public methods
*********/
/// <summary>Construct an instance.</summary>
+ /// <param name="name">The mod name.</param>
+ /// <param name="alternateNames">The mod's alternative names, if any.</param>
+ /// <param name="author">The mod author's name.</param>
+ /// <param name="alternateAuthors">The mod author's alternative names, if any.</param>
+ /// <param name="gitHubRepo">The GitHub repo, if any.</param>
+ /// <param name="sourceUrl">The URL to the mod's source code, if any.</param>
+ /// <param name="compatibility">The compatibility status for the stable version of the game.</param>
+ /// <param name="betaCompatibility">The compatibility status for the beta version of the game.</param>
+ /// <param name="modPages">Links to the available mod pages.</param>
+ /// <param name="warnings">The human-readable warnings for players about this mod.</param>
+ /// <param name="pullRequestUrl">The URL of the pull request which submits changes for an unofficial update to the author, if any.</param>
+ /// <param name="devNote">Special notes intended for developers who maintain unofficial updates or submit pull requests.</param>
+ /// <param name="slug">A unique identifier for the mod that can be used in an anchor URL.</param>
+ [JsonConstructor]
+ public ModModel(string? name, string alternateNames, string author, string alternateAuthors, string gitHubRepo, string sourceUrl, ModCompatibilityModel compatibility, ModCompatibilityModel betaCompatibility, ModLinkModel[] modPages, string[] warnings, string pullRequestUrl, string devNote, string slug)
+ {
+ this.Name = name;
+ this.AlternateNames = alternateNames;
+ this.Author = author;
+ this.AlternateAuthors = alternateAuthors;
+ this.GitHubRepo = gitHubRepo;
+ this.SourceUrl = sourceUrl;
+ this.Compatibility = compatibility;
+ this.BetaCompatibility = betaCompatibility;
+ this.ModPages = modPages;
+ this.Warnings = warnings;
+ this.PullRequestUrl = pullRequestUrl;
+ this.DevNote = devNote;
+ this.Slug = slug;
+ }
+
+ /// <summary>Construct an instance.</summary>
/// <param name="entry">The mod metadata.</param>
public ModModel(WikiModEntry entry)
{
@@ -84,7 +115,7 @@ namespace StardewModdingAPI.Web.ViewModels
*********/
/// <summary>Get the web URL for the mod's source code repository, if any.</summary>
/// <param name="entry">The mod metadata.</param>
- private string GetSourceUrl(WikiModEntry entry)
+ private string? GetSourceUrl(WikiModEntry entry)
{
if (!string.IsNullOrWhiteSpace(entry.GitHubRepo))
return $"https://github.com/{entry.GitHubRepo}";