2023-04-07 14:57:41 -04:00
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using SabreTools.Core;
|
2024-03-05 01:42:42 -05:00
|
|
|
using SabreTools.Filter;
|
2023-04-07 14:57:41 -04:00
|
|
|
|
|
|
|
|
// TODO: Add item mappings for all fields
|
|
|
|
|
namespace SabreTools.DatItems.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents a single serials item
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonObject("serials"), XmlRoot("serials")]
|
|
|
|
|
public class Serials : DatItem
|
|
|
|
|
{
|
|
|
|
|
#region Fields
|
|
|
|
|
|
2023-04-19 12:26:54 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Digital serial 1 value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("digital_serial1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("digital_serial1")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? DigitalSerial1 { get; set; }
|
2023-04-19 12:26:54 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Digital serial 2 value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("digital_serial2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("digital_serial2")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? DigitalSerial2 { get; set; }
|
2023-04-19 12:26:54 -04:00
|
|
|
|
2023-04-07 14:57:41 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Media serial 1 value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("media_serial1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("media_serial1")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? MediaSerial1 { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Media serial 2 value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("media_serial2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("media_serial2")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? MediaSerial2 { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
2023-04-19 12:26:54 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Media serial 3 value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("media_serial3", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("media_serial3")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? MediaSerial3 { get; set; }
|
2023-04-19 12:26:54 -04:00
|
|
|
|
2023-04-07 14:57:41 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// PCB serial value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("pcb_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("pcb_serial")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? PcbSerial { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Rom chip serial 1 value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("romchip_serial1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("romchip_serial1")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? RomChipSerial1 { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Rom chip serial 2 value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("romchip_serial2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("romchip_serial2")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? RomChipSerial2 { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Lockout serial value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("lockout_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("lockout_serial")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? LockoutSerial { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Save chip serial value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("savechip_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("savechip_serial")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? SaveChipSerial { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
2023-04-19 12:26:54 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Chip serial value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("chip_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("chip_serial")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? ChipSerial { get; set; }
|
2023-04-19 12:26:54 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Box serial value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("box_serial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("box_serial")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? BoxSerial { get; set; }
|
2023-04-19 12:26:54 -04:00
|
|
|
|
2023-04-07 14:57:41 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Media stamp value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("mediastamp", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("mediastamp")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? MediaStamp { get; set; }
|
2023-04-07 14:57:41 -04:00
|
|
|
|
2023-04-19 12:26:54 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Box barcode value
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("box_barcode", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("box_barcode")]
|
2023-08-14 13:17:51 -04:00
|
|
|
public string? BoxBarcode { get; set; }
|
2023-04-19 12:26:54 -04:00
|
|
|
|
2023-04-07 14:57:41 -04:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a default, empty Serials object
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Serials()
|
|
|
|
|
{
|
|
|
|
|
ItemType = ItemType.Serials;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override object Clone()
|
|
|
|
|
{
|
|
|
|
|
return new Serials()
|
|
|
|
|
{
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
2023-08-15 01:38:01 -04:00
|
|
|
Machine = this.Machine.Clone() as Machine ?? new Machine(),
|
2023-08-14 13:17:51 -04:00
|
|
|
Source = this.Source?.Clone() as Source,
|
2023-04-07 14:57:41 -04:00
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
2023-04-19 12:26:54 -04:00
|
|
|
DigitalSerial1 = this.DigitalSerial1,
|
|
|
|
|
DigitalSerial2 = this.DigitalSerial2,
|
2023-04-07 14:57:41 -04:00
|
|
|
MediaSerial1 = this.MediaSerial1,
|
|
|
|
|
MediaSerial2 = this.MediaSerial2,
|
2023-04-19 12:26:54 -04:00
|
|
|
MediaSerial3 = this.MediaSerial3,
|
2023-04-07 14:57:41 -04:00
|
|
|
PcbSerial = this.PcbSerial,
|
|
|
|
|
RomChipSerial1 = this.RomChipSerial1,
|
|
|
|
|
RomChipSerial2 = this.RomChipSerial2,
|
|
|
|
|
LockoutSerial = this.LockoutSerial,
|
|
|
|
|
SaveChipSerial = this.SaveChipSerial,
|
2023-04-19 12:26:54 -04:00
|
|
|
ChipSerial = this.ChipSerial,
|
|
|
|
|
BoxSerial = this.BoxSerial,
|
2023-04-07 14:57:41 -04:00
|
|
|
MediaStamp = this.MediaStamp,
|
2023-04-19 12:26:54 -04:00
|
|
|
BoxBarcode = this.BoxBarcode,
|
2023-04-07 14:57:41 -04:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Comparision Methods
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
public override bool Equals(DatItem? other)
|
2023-04-07 14:57:41 -04:00
|
|
|
{
|
|
|
|
|
// If we don't have a Serials, return false
|
2023-08-14 13:17:51 -04:00
|
|
|
if (ItemType != other?.ItemType)
|
2023-04-07 14:57:41 -04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Otherwise, treat it as a Serials
|
2023-08-14 13:17:51 -04:00
|
|
|
Serials? newOther = other as Serials;
|
2023-04-07 14:57:41 -04:00
|
|
|
|
|
|
|
|
// If the Serials information matches
|
2023-08-14 13:17:51 -04:00
|
|
|
return (DigitalSerial1 == newOther!.DigitalSerial1
|
2023-04-19 12:26:54 -04:00
|
|
|
&& DigitalSerial2 == newOther.DigitalSerial2
|
|
|
|
|
&& MediaSerial1 == newOther.MediaSerial1
|
2023-04-07 14:57:41 -04:00
|
|
|
&& MediaSerial2 == newOther.MediaSerial2
|
2023-04-19 12:26:54 -04:00
|
|
|
&& MediaSerial3 == newOther.MediaSerial3
|
2023-04-07 14:57:41 -04:00
|
|
|
&& PcbSerial == newOther.PcbSerial
|
|
|
|
|
&& RomChipSerial1 == newOther.RomChipSerial1
|
|
|
|
|
&& RomChipSerial2 == newOther.RomChipSerial2
|
|
|
|
|
&& LockoutSerial == newOther.LockoutSerial
|
|
|
|
|
&& SaveChipSerial == newOther.SaveChipSerial
|
2023-04-19 12:26:54 -04:00
|
|
|
&& ChipSerial == newOther.ChipSerial
|
|
|
|
|
&& BoxSerial == newOther.BoxSerial
|
|
|
|
|
&& MediaStamp == newOther.MediaStamp
|
|
|
|
|
&& BoxBarcode == newOther.BoxBarcode);
|
2023-04-07 14:57:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2024-03-05 01:42:42 -05:00
|
|
|
|
|
|
|
|
#region Manipulation
|
|
|
|
|
|
2024-03-05 02:20:12 -05:00
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override bool SetField(DatItemField datItemField, string value)
|
|
|
|
|
{
|
|
|
|
|
// Get the correct internal field name
|
|
|
|
|
string? fieldName = datItemField switch
|
|
|
|
|
{
|
|
|
|
|
// TODO: Figure out what fields go here
|
|
|
|
|
_ => null,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Set the field and return
|
|
|
|
|
return FieldManipulator.SetField(_internal, fieldName, value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-05 01:42:42 -05:00
|
|
|
#endregion
|
2023-04-07 14:57:41 -04:00
|
|
|
}
|
|
|
|
|
}
|