diff --git a/SabreTools.Data.Models/Metadata/Analog.cs b/SabreTools.Data.Models/Metadata/Analog.cs index f8b06d45..c99da0f0 100644 --- a/SabreTools.Data.Models/Metadata/Analog.cs +++ b/SabreTools.Data.Models/Metadata/Analog.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("analog"), XmlRoot("analog")] - public class Analog : DatItem, ICloneable + public class Analog : DatItem, ICloneable, IEquatable { #region Properties @@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(Analog? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Mask is null) ^ (other.Mask is null)) + return false; + else if (Mask is not null && !Mask.Equals(other.Mask, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/BiosSet.cs b/SabreTools.Data.Models/Metadata/BiosSet.cs index b3885fba..d8d89f38 100644 --- a/SabreTools.Data.Models/Metadata/BiosSet.cs +++ b/SabreTools.Data.Models/Metadata/BiosSet.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("biosset"), XmlRoot("biosset")] - public class BiosSet : DatItem, ICloneable + public class BiosSet : DatItem, ICloneable, IEquatable { #region Properties @@ -31,5 +31,29 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(BiosSet? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if (Default != other.Default) + return false; + + if ((Description is null) ^ (other.Description is null)) + return false; + else if (Description is not null && !Description.Equals(other.Description, StringComparison.OrdinalIgnoreCase)) + return false; + + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/Blank.cs b/SabreTools.Data.Models/Metadata/Blank.cs index 679bc352..8d095192 100644 --- a/SabreTools.Data.Models/Metadata/Blank.cs +++ b/SabreTools.Data.Models/Metadata/Blank.cs @@ -5,11 +5,14 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("blank"), XmlRoot("blank")] - public class Blank : DatItem, ICloneable + public class Blank : DatItem, ICloneable, IEquatable { public Blank() => ItemType = ItemType.Blank; /// public object Clone() => new Blank(); + + /// + public bool Equals(Blank? other) => other is not null; } } diff --git a/SabreTools.Data.Models/Metadata/Condition.cs b/SabreTools.Data.Models/Metadata/Condition.cs index 7c06f776..b6daea52 100644 --- a/SabreTools.Data.Models/Metadata/Condition.cs +++ b/SabreTools.Data.Models/Metadata/Condition.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("condition"), XmlRoot("condition")] - public class Condition : DatItem, ICloneable + public class Condition : DatItem, ICloneable, IEquatable { #region Properties @@ -34,5 +34,34 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(Condition? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Mask is null) ^ (other.Mask is null)) + return false; + else if (Mask is not null && !Mask.Equals(other.Mask, StringComparison.OrdinalIgnoreCase)) + return false; + + if (Relation != other.Relation) + return false; + + if ((Tag is null) ^ (other.Tag is null)) + return false; + else if (Tag is not null && !Tag.Equals(other.Tag, StringComparison.OrdinalIgnoreCase)) + return false; + + if ((Value is null) ^ (other.Value is null)) + return false; + else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/DeviceRef.cs b/SabreTools.Data.Models/Metadata/DeviceRef.cs index a6989c93..36cfbc7b 100644 --- a/SabreTools.Data.Models/Metadata/DeviceRef.cs +++ b/SabreTools.Data.Models/Metadata/DeviceRef.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("device_ref"), XmlRoot("device_ref")] - public class DeviceRef : DatItem, ICloneable + public class DeviceRef : DatItem, ICloneable, IEquatable { #region Properties @@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(DeviceRef? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/Extension.cs b/SabreTools.Data.Models/Metadata/Extension.cs index e61009c7..c3723b51 100644 --- a/SabreTools.Data.Models/Metadata/Extension.cs +++ b/SabreTools.Data.Models/Metadata/Extension.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("extension"), XmlRoot("extension")] - public class Extension : DatItem, ICloneable + public class Extension : DatItem, ICloneable, IEquatable { #region Properties @@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(Extension? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/Feature.cs b/SabreTools.Data.Models/Metadata/Feature.cs index 1162791a..4f108c31 100644 --- a/SabreTools.Data.Models/Metadata/Feature.cs +++ b/SabreTools.Data.Models/Metadata/Feature.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("feature"), XmlRoot("feature")] - public class Feature : DatItem, ICloneable + public class Feature : DatItem, ICloneable, IEquatable { #region Properties @@ -39,5 +39,35 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(Feature? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if (FeatureType != other.FeatureType) + return false; + + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + if (Overall != other.Overall) + return false; + + if (Status != other.Status) + return false; + + if ((Value is null) ^ (other.Value is null)) + return false; + else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/Info.cs b/SabreTools.Data.Models/Metadata/Info.cs index 4e073bfe..337d85c8 100644 --- a/SabreTools.Data.Models/Metadata/Info.cs +++ b/SabreTools.Data.Models/Metadata/Info.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("info"), XmlRoot("info")] - public class Info : DatItem, ICloneable + public class Info : DatItem, ICloneable, IEquatable { #region Properties @@ -27,5 +27,26 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(Info? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + if ((Value is null) ^ (other.Value is null)) + return false; + else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/Instance.cs b/SabreTools.Data.Models/Metadata/Instance.cs index 4ca57882..949caf2d 100644 --- a/SabreTools.Data.Models/Metadata/Instance.cs +++ b/SabreTools.Data.Models/Metadata/Instance.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("instance"), XmlRoot("instance")] - public class Instance : DatItem, ICloneable + public class Instance : DatItem, ICloneable, IEquatable { #region Properties @@ -27,5 +27,26 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(Instance? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((BriefName is null) ^ (other.BriefName is null)) + return false; + else if (BriefName is not null && !BriefName.Equals(other.BriefName, StringComparison.OrdinalIgnoreCase)) + return false; + + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/RamOption.cs b/SabreTools.Data.Models/Metadata/RamOption.cs index 5ff841a7..be355680 100644 --- a/SabreTools.Data.Models/Metadata/RamOption.cs +++ b/SabreTools.Data.Models/Metadata/RamOption.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("ramoption"), XmlRoot("ramoption")] - public class RamOption : DatItem, ICloneable + public class RamOption : DatItem, ICloneable, IEquatable { #region Properties @@ -31,5 +31,29 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(RamOption? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Content is null) ^ (other.Content is null)) + return false; + else if (Content is not null && !Content.Equals(other.Content, StringComparison.OrdinalIgnoreCase)) + return false; + + if (Default != other.Default) + return false; + + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/Sample.cs b/SabreTools.Data.Models/Metadata/Sample.cs index 604a3def..fb5bcfdf 100644 --- a/SabreTools.Data.Models/Metadata/Sample.cs +++ b/SabreTools.Data.Models/Metadata/Sample.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("sample"), XmlRoot("sample")] - public class Sample : DatItem, ICloneable + public class Sample : DatItem, IEquatable { #region Properties @@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(Sample? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/SharedFeat.cs b/SabreTools.Data.Models/Metadata/SharedFeat.cs index 4eac6bf1..336d03e7 100644 --- a/SabreTools.Data.Models/Metadata/SharedFeat.cs +++ b/SabreTools.Data.Models/Metadata/SharedFeat.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("sharedfeat"), XmlRoot("sharedfeat")] - public class SharedFeat : DatItem, ICloneable + public class SharedFeat : DatItem, ICloneable, IEquatable { #region Properties @@ -27,5 +27,26 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(SharedFeat? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + if ((Value is null) ^ (other.Value is null)) + return false; + else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } } diff --git a/SabreTools.Data.Models/Metadata/SlotOption.cs b/SabreTools.Data.Models/Metadata/SlotOption.cs index a1ac2c13..e817a952 100644 --- a/SabreTools.Data.Models/Metadata/SlotOption.cs +++ b/SabreTools.Data.Models/Metadata/SlotOption.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; namespace SabreTools.Data.Models.Metadata { [JsonObject("slotoption"), XmlRoot("slotoption")] - public class SlotOption : DatItem, ICloneable + public class SlotOption : DatItem, ICloneable, IEquatable { #region Properties @@ -31,5 +31,29 @@ namespace SabreTools.Data.Models.Metadata return obj; } + + /// + public bool Equals(SlotOption? other) + { + // Null never matches + if (other is null) + return false; + + // Properties + if (Default != other.Default) + return false; + + if ((DevName is null) ^ (other.DevName is null)) + return false; + else if (DevName is not null && !DevName.Equals(other.DevName, StringComparison.OrdinalIgnoreCase)) + return false; + + if ((Name is null) ^ (other.Name is null)) + return false; + else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase)) + return false; + + return true; + } } }