Files
SabreTools/SabreTools.DatItems/Formats/SoftwareList.cs
2024-03-10 17:00:11 -04:00

66 lines
1.8 KiB
C#

using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
namespace SabreTools.DatItems.Formats
{
/// <summary>
/// Represents which SoftwareList(s) is associated with a set
/// </summary>
/// <remarks>
/// TODO: Add new fields to documentation
/// </remarks>
[JsonObject("softwarelist"), XmlRoot("softwarelist")]
public class SoftwareList : DatItem
{
#region Accessors
/// <inheritdoc/>
public override string? GetName() => GetFieldValue<string>(Models.Metadata.SoftwareList.NameKey);
/// <inheritdoc/>
public override void SetName(string? name) => SetFieldValue(Models.Metadata.SoftwareList.NameKey, name);
#endregion
#region Constructors
/// <summary>
/// Create a default, empty SoftwareList object
/// </summary>
public SoftwareList()
{
_internal = new Models.Metadata.SoftwareList();
SetName(string.Empty);
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.SoftwareList);
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
}
/// <summary>
/// Create a SoftwareList object from the internal model
/// </summary>
public SoftwareList(Models.Metadata.SoftwareList item)
{
_internal = item;
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.SoftwareList);
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
}
#endregion
#region Cloning Methods
public override object Clone()
{
return new SoftwareList()
{
_internal = this._internal?.Clone() as Models.Metadata.SoftwareList ?? [],
};
}
#endregion
}
}