mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
Make "simple" metadata items equatable
This commit is contained in:
@@ -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<Analog>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<BiosSet>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -31,5 +31,29 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Blank>
|
||||
{
|
||||
public Blank() => ItemType = ItemType.Blank;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object Clone() => new Blank();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Blank? other) => other is not null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Condition>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -34,5 +34,34 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<DeviceRef>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Extension>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Feature>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -39,5 +39,35 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Info>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -27,5 +27,26 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Instance>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -27,5 +27,26 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<RamOption>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -31,5 +31,29 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Sample>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -24,5 +24,21 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SharedFeat>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -27,5 +27,26 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SlotOption>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -31,5 +31,29 @@ namespace SabreTools.Data.Models.Metadata
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user