From 274919fd6a4e43265993049ca1a9b473adfb82ce Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 4 Apr 2026 14:23:27 -0400 Subject: [PATCH] Convert Dump to using properties --- SabreTools.Data.Models/Metadata/Dump.cs | 69 ++++++++++++++++++++----- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/SabreTools.Data.Models/Metadata/Dump.cs b/SabreTools.Data.Models/Metadata/Dump.cs index f4ca3c33..69a39c6a 100644 --- a/SabreTools.Data.Models/Metadata/Dump.cs +++ b/SabreTools.Data.Models/Metadata/Dump.cs @@ -1,31 +1,72 @@ +using System; using System.Xml.Serialization; using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("dump"), XmlRoot("dump")] - public class Dump : DatItem + public class Dump : DatItem, ICloneable, IEquatable { - #region Keys + #region Properties - /// Rom - [NoFilter] - public const string MegaRomKey = "megarom"; + public Rom? MegaRom { get; set; } - /// Original - [NoFilter] - public const string OriginalKey = "original"; + public Original? Original { get; set; } - /// Rom - [NoFilter] - public const string RomKey = "rom"; + public Rom? Rom { get; set; } - /// Rom - [NoFilter] - public const string SCCPlusCartKey = "sccpluscart"; + public Rom? SCCPlusCart { get; set; } #endregion public Dump() => ItemType = ItemType.Dump; + + /// + public object Clone() + { + var obj = new Dump(); + + if (MegaRom is not null) + obj.MegaRom = MegaRom.Clone() as Rom; + if (Original is not null) + obj.Original = Original.Clone() as Original; + if (Rom is not null) + obj.Rom = Rom.Clone() as Rom; + if (SCCPlusCart is not null) + obj.SCCPlusCart = SCCPlusCart.Clone() as Rom; + + return obj; + } + + /// + public bool Equals(Dump? other) + { + // Null never matches + if (other is null) + return false; + + // Sub-items + if ((MegaRom is null) ^ (other.MegaRom is null)) + return false; + else if (MegaRom is not null && other.MegaRom is not null && MegaRom.Equals(other.MegaRom)) + return false; + + if ((Original is null) ^ (other.Original is null)) + return false; + else if (Original is not null && other.Original is not null && Original.Equals(other.Original)) + return false; + + if ((Rom is null) ^ (other.Rom is null)) + return false; + else if (Rom is not null && other.Rom is not null && Rom.Equals(other.Rom)) + return false; + + if ((SCCPlusCart is null) ^ (other.SCCPlusCart is null)) + return false; + else if (SCCPlusCart is not null && other.SCCPlusCart is not null && SCCPlusCart.Equals(other.SCCPlusCart)) + return false; + + return true; + } } }