finalize model for option sets

This commit is contained in:
Pascal
2025-06-27 09:29:57 +02:00
parent f5596ab0ba
commit d0e3d2fa61
7 changed files with 46 additions and 12 deletions

View File

@@ -0,0 +1,6 @@
namespace ModpackUpdater;
public interface IActionSet
{
IEnumerable<InstallAction> Actions { get; }
}

View File

@@ -1,10 +1,7 @@
namespace ModpackUpdater; namespace ModpackUpdater;
public interface IActionSetInfos public interface IActionSetInfos : IActionSet
{ {
Version Version { get; set; } Version Version { get; set; }
bool IsPublic { get; set; }
public bool IsPublic { get; set; }
IEnumerable<InstallAction> Actions { get; }
} }

View File

@@ -50,6 +50,9 @@ public class InstallAction
[DefaultValue(false)] [DefaultValue(false)]
public bool IsExtra { get; set; } public bool IsExtra { get; set; }
[DefaultValue(null)]
public string TargetOption { get; set; }
[JsonProperty, Obsolete] [JsonProperty, Obsolete]
private string DownloadUrl private string DownloadUrl
{ {

View File

@@ -15,7 +15,7 @@ public class InstallInfos : IActionSetInfos
public List<InstallOptionSet> OptionSets { get; } = []; public List<InstallOptionSet> OptionSets { get; } = [];
IEnumerable<InstallAction> IActionSetInfos.Actions => Actions; IEnumerable<InstallAction> IActionSet.Actions => Actions;
public static InstallInfos Parse(string content) public static InstallInfos Parse(string content)
{ {

View File

@@ -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 string Id { get; set; }
public List<InstallAction> InstallActions { get; } = [];
[DefaultValue(null)]
public string Description { get; set; }
[DefaultValue(Side.Both)]
[JsonConverter(typeof(StringEnumConverter))]
public Side Side { get; set; } = Side.Both;
public List<UpdateAction> UninstallActions { get; } = []; public List<UpdateAction> UninstallActions { get; } = [];
IEnumerable<InstallAction> IActionSet.Actions => UninstallActions.Cast<InstallAction>();
} }

View File

@@ -1,9 +1,24 @@
namespace ModpackUpdater; using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;
namespace ModpackUpdater;
public class InstallOptionSet public class InstallOptionSet
{ {
public string Id { get; set; } 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 bool Multiselect { get; set; }
public string DefaultValue { get; set; }
public List<int> Defaults { get; } = [];
public List<InstallOption> Options { get; } = []; public List<InstallOption> Options { get; } = [];
} }

View File

@@ -13,5 +13,5 @@ public class UpdateInfo : IActionSetInfos
public List<UpdateAction> Actions { get; } = []; public List<UpdateAction> Actions { get; } = [];
IEnumerable<InstallAction> IActionSetInfos.Actions => Actions.Cast<InstallAction>(); IEnumerable<InstallAction> IActionSet.Actions => Actions.Cast<InstallAction>();
} }