Files
SabreTools/SabreTools.DatItems/Formats/Chip.cs
2024-03-09 21:46:38 -05:00

71 lines
1.7 KiB
C#

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