Files
SabreTools/SabreTools.DatItems/Formats/SoftwareList.cs

116 lines
3.4 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
2020-08-31 23:26:07 -07:00
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SabreTools.Core;
using SabreTools.Core.Tools;
2020-08-31 23:26:07 -07:00
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
2020-08-31 23:26:07 -07:00
{
/// <summary>
/// Represents which SoftwareList(s) is associated with a set
/// </summary>
2022-11-03 12:22:17 -07:00
/// <remarks>
/// TODO: Add new fields to documentation
/// </remarks>
2020-09-08 10:12:41 -07:00
[JsonObject("softwarelist"), XmlRoot("softwarelist")]
2020-08-31 23:26:07 -07:00
public class SoftwareList : DatItem
{
#region Fields
2022-11-03 11:44:29 -07:00
/// <summary>
/// Tag for the software list
/// </summary>
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("tag")]
public string? Tag
{
2023-09-04 23:51:37 -04:00
get => _internal.ReadString(Models.Metadata.SoftwareList.TagKey);
set => _internal[Models.Metadata.SoftwareList.TagKey] = value;
}
2022-11-03 11:44:29 -07:00
2020-09-02 12:19:12 -07:00
/// <summary>
/// Name of the item
/// </summary>
[JsonProperty("name")]
2020-09-07 22:00:02 -07:00
[XmlElement("name")]
public string? Name
{
2023-09-04 23:51:37 -04:00
get => _internal.ReadString(Models.Metadata.SoftwareList.NameKey);
set => _internal[Models.Metadata.SoftwareList.NameKey] = value;
}
2020-09-02 12:19:12 -07:00
/// <summary>
/// Status of the softare list according to the machine
/// </summary>
2020-08-31 23:26:07 -07:00
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("status")]
public SoftwareListStatus Status
{
2023-09-04 23:51:37 -04:00
get => _internal.ReadString(Models.Metadata.SoftwareList.StatusKey).AsSoftwareListStatus();
set => _internal[Models.Metadata.SoftwareList.StatusKey] = value.FromSoftwareListStatus();
}
2020-08-31 23:26:07 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
2023-04-20 10:34:37 -04:00
public bool StatusSpecified { get { return Status != SoftwareListStatus.None; } }
2020-09-07 22:00:02 -07:00
2020-09-02 12:19:12 -07:00
/// <summary>
/// Filter to apply to the software list
/// </summary>
2020-08-31 23:26:07 -07:00
[JsonProperty("filter", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("filter")]
public string? Filter
{
2023-09-04 23:51:37 -04:00
get => _internal.ReadString(Models.Metadata.SoftwareList.FilterKey);
set => _internal[Models.Metadata.SoftwareList.FilterKey] = value;
}
2020-08-31 23:26:07 -07:00
#endregion
#region Accessors
/// <inheritdoc/>
public override string? GetName() => Name;
2020-09-02 12:19:12 -07:00
/// <inheritdoc/>
public override void SetName(string? name) => Name = name;
2020-08-31 23:26:07 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty SoftwareList object
/// </summary>
public SoftwareList()
{
2023-09-04 23:51:37 -04:00
_internal = new Models.Metadata.SoftwareList();
2023-08-15 01:38:01 -04:00
Machine = new Machine();
2020-08-31 23:26:07 -07:00
Name = string.Empty;
ItemType = ItemType.SoftwareList;
}
#endregion
#region Cloning Methods
public override object Clone()
{
return new SoftwareList()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
2023-08-15 01:38:01 -04:00
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
2020-08-31 23:26:07 -07:00
Remove = this.Remove,
2023-09-04 23:51:37 -04:00
_internal = this._internal?.Clone() as Models.Metadata.SoftwareList ?? new Models.Metadata.SoftwareList(),
2020-08-31 23:26:07 -07:00
};
}
#endregion
}
}