From d0e3d2fa6192e8432290c083467c70b381aadccf Mon Sep 17 00:00:00 2001 From: Pascal Date: Fri, 27 Jun 2025 09:29:57 +0200 Subject: [PATCH] finalize model for option sets --- ModpackUpdater/IActionSet.cs | 6 ++++++ ModpackUpdater/IActionSetInfos.cs | 7 ++----- ModpackUpdater/InstallAction.cs | 3 +++ ModpackUpdater/InstallInfos.cs | 2 +- ModpackUpdater/InstallOption.cs | 19 ++++++++++++++++--- ModpackUpdater/InstallOptionSet.cs | 19 +++++++++++++++++-- ModpackUpdater/UpdateInfo.cs | 2 +- 7 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 ModpackUpdater/IActionSet.cs diff --git a/ModpackUpdater/IActionSet.cs b/ModpackUpdater/IActionSet.cs new file mode 100644 index 0000000..19af91a --- /dev/null +++ b/ModpackUpdater/IActionSet.cs @@ -0,0 +1,6 @@ +namespace ModpackUpdater; + +public interface IActionSet +{ + IEnumerable Actions { get; } +} diff --git a/ModpackUpdater/IActionSetInfos.cs b/ModpackUpdater/IActionSetInfos.cs index 3293ed7..3d96f17 100644 --- a/ModpackUpdater/IActionSetInfos.cs +++ b/ModpackUpdater/IActionSetInfos.cs @@ -1,10 +1,7 @@ namespace ModpackUpdater; -public interface IActionSetInfos +public interface IActionSetInfos : IActionSet { Version Version { get; set; } - - public bool IsPublic { get; set; } - - IEnumerable Actions { get; } + bool IsPublic { get; set; } } diff --git a/ModpackUpdater/InstallAction.cs b/ModpackUpdater/InstallAction.cs index eaef33d..bca679e 100644 --- a/ModpackUpdater/InstallAction.cs +++ b/ModpackUpdater/InstallAction.cs @@ -50,6 +50,9 @@ public class InstallAction [DefaultValue(false)] public bool IsExtra { get; set; } + [DefaultValue(null)] + public string TargetOption { get; set; } + [JsonProperty, Obsolete] private string DownloadUrl { diff --git a/ModpackUpdater/InstallInfos.cs b/ModpackUpdater/InstallInfos.cs index 5280e7d..207ba4f 100644 --- a/ModpackUpdater/InstallInfos.cs +++ b/ModpackUpdater/InstallInfos.cs @@ -15,7 +15,7 @@ public class InstallInfos : IActionSetInfos public List OptionSets { get; } = []; - IEnumerable IActionSetInfos.Actions => Actions; + IEnumerable IActionSet.Actions => Actions; public static InstallInfos Parse(string content) { diff --git a/ModpackUpdater/InstallOption.cs b/ModpackUpdater/InstallOption.cs index b8578ac..380fae4 100644 --- a/ModpackUpdater/InstallOption.cs +++ b/ModpackUpdater/InstallOption.cs @@ -1,8 +1,21 @@ -namespace ModpackUpdater; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; -public class InstallOption +namespace ModpackUpdater; + +public class InstallOption : IActionSet { public string Id { get; set; } - public List InstallActions { get; } = []; + + [DefaultValue(null)] + public string Description { get; set; } + + [DefaultValue(Side.Both)] + [JsonConverter(typeof(StringEnumConverter))] + public Side Side { get; set; } = Side.Both; + public List UninstallActions { get; } = []; + + IEnumerable IActionSet.Actions => UninstallActions.Cast(); } diff --git a/ModpackUpdater/InstallOptionSet.cs b/ModpackUpdater/InstallOptionSet.cs index 407d064..9b21af8 100644 --- a/ModpackUpdater/InstallOptionSet.cs +++ b/ModpackUpdater/InstallOptionSet.cs @@ -1,9 +1,24 @@ -namespace ModpackUpdater; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; + +namespace ModpackUpdater; public class InstallOptionSet { public string Id { get; set; } + + [DefaultValue(null)] + public string Description { get; set; } + + [DefaultValue(Side.Both)] + [JsonConverter(typeof(StringEnumConverter))] + public Side Side { get; set; } = Side.Both; + + [DefaultValue(false)] public bool Multiselect { get; set; } - public string DefaultValue { get; set; } + + public List Defaults { get; } = []; + public List Options { get; } = []; } diff --git a/ModpackUpdater/UpdateInfo.cs b/ModpackUpdater/UpdateInfo.cs index 30ece9c..eb31ed3 100644 --- a/ModpackUpdater/UpdateInfo.cs +++ b/ModpackUpdater/UpdateInfo.cs @@ -13,5 +13,5 @@ public class UpdateInfo : IActionSetInfos public List Actions { get; } = []; - IEnumerable IActionSetInfos.Actions => Actions.Cast(); + IEnumerable IActionSet.Actions => Actions.Cast(); } \ No newline at end of file