using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
using SabreTools.Filter;
// TODO: Add item mappings for all fields
namespace SabreTools.DatItems.Formats
{
///
/// Represents a single serials item
///
[JsonObject("serials"), XmlRoot("serials")]
public class Serials : DatItem
{
#region Fields
///
/// Digital serial 1 value
///
[JsonProperty("digital_serial1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("digital_serial1")]
public string? DigitalSerial1 { get; set; }
///
/// Digital serial 2 value
///
[JsonProperty("digital_serial2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("digital_serial2")]
public string? DigitalSerial2 { get; set; }
///
/// Media serial 1 value
///
[JsonProperty("media_serial1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("media_serial1")]
public string? MediaSerial1 { get; set; }
///
/// Media serial 2 value
///
[JsonProperty("media_serial2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("media_serial2")]
public string? MediaSerial2 { get; set; }
///
/// Media serial 3 value
///
[JsonProperty("media_serial3", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("media_serial3")]
public string? MediaSerial3 { get; set; }
///
/// PCB serial value
///
[JsonProperty("pcb_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("pcb_serial")]
public string? PcbSerial { get; set; }
///
/// Rom chip serial 1 value
///
[JsonProperty("romchip_serial1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("romchip_serial1")]
public string? RomChipSerial1 { get; set; }
///
/// Rom chip serial 2 value
///
[JsonProperty("romchip_serial2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("romchip_serial2")]
public string? RomChipSerial2 { get; set; }
///
/// Lockout serial value
///
[JsonProperty("lockout_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("lockout_serial")]
public string? LockoutSerial { get; set; }
///
/// Save chip serial value
///
[JsonProperty("savechip_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("savechip_serial")]
public string? SaveChipSerial { get; set; }
///
/// Chip serial value
///
[JsonProperty("chip_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("chip_serial")]
public string? ChipSerial { get; set; }
///
/// Box serial value
///
[JsonProperty("box_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("box_serial")]
public string? BoxSerial { get; set; }
///
/// Media stamp value
///
[JsonProperty("mediastamp", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("mediastamp")]
public string? MediaStamp { get; set; }
///
/// Box barcode value
///
[JsonProperty("box_barcode", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("box_barcode")]
public string? BoxBarcode { get; set; }
#endregion
#region Constructors
///
/// Create a default, empty Serials object
///
public Serials()
{
ItemType = ItemType.Serials;
}
#endregion
#region Cloning Methods
///
public override object Clone()
{
return new Serials()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
DigitalSerial1 = this.DigitalSerial1,
DigitalSerial2 = this.DigitalSerial2,
MediaSerial1 = this.MediaSerial1,
MediaSerial2 = this.MediaSerial2,
MediaSerial3 = this.MediaSerial3,
PcbSerial = this.PcbSerial,
RomChipSerial1 = this.RomChipSerial1,
RomChipSerial2 = this.RomChipSerial2,
LockoutSerial = this.LockoutSerial,
SaveChipSerial = this.SaveChipSerial,
ChipSerial = this.ChipSerial,
BoxSerial = this.BoxSerial,
MediaStamp = this.MediaStamp,
BoxBarcode = this.BoxBarcode,
};
}
#endregion
#region Comparision Methods
///
public override bool Equals(DatItem? other)
{
// If we don't have a Serials, return false
if (ItemType != other?.ItemType)
return false;
// Otherwise, treat it as a Serials
Serials? newOther = other as Serials;
// If the Serials information matches
return (DigitalSerial1 == newOther!.DigitalSerial1
&& DigitalSerial2 == newOther.DigitalSerial2
&& MediaSerial1 == newOther.MediaSerial1
&& MediaSerial2 == newOther.MediaSerial2
&& MediaSerial3 == newOther.MediaSerial3
&& PcbSerial == newOther.PcbSerial
&& RomChipSerial1 == newOther.RomChipSerial1
&& RomChipSerial2 == newOther.RomChipSerial2
&& LockoutSerial == newOther.LockoutSerial
&& SaveChipSerial == newOther.SaveChipSerial
&& ChipSerial == newOther.ChipSerial
&& BoxSerial == newOther.BoxSerial
&& MediaStamp == newOther.MediaStamp
&& BoxBarcode == newOther.BoxBarcode);
}
#endregion
}
}