Move one Equals implementation to correct base class

This commit is contained in:
Matt Nadareski
2025-01-08 14:43:34 -05:00
parent 9ed9c512f4
commit ee32d26148
3 changed files with 16 additions and 17 deletions

View File

@@ -1,4 +1,3 @@
using SabreTools.Core.Filter;
using SabreTools.DatItems.Formats; using SabreTools.DatItems.Formats;
using Xunit; using Xunit;

View File

@@ -174,6 +174,21 @@ namespace SabreTools.DatItems
return string.Compare(selfName, otherName, StringComparison.Ordinal); return string.Compare(selfName, otherName, StringComparison.Ordinal);
} }
/// <inheritdoc/>
public override bool Equals(ModelBackedItem? other)
{
// If other is null
if (other == null)
return false;
// If the type is mismatched
if (other is not DatItem otherItem)
return false;
// Compare internal models
return _internal.Equals(otherItem);
}
/// <summary> /// <summary>
/// Determine if an item is a duplicate using partial matching logic /// Determine if an item is a duplicate using partial matching logic
/// </summary> /// </summary>
@@ -582,21 +597,6 @@ namespace SabreTools.DatItems
return string.Compare(selfName, otherName, StringComparison.Ordinal); return string.Compare(selfName, otherName, StringComparison.Ordinal);
} }
/// <inheritdoc/>
public override bool Equals(ModelBackedItem? other)
{
// If other is null
if (other == null)
return false;
// If the type is mismatched
if (other is not DatItem<T> otherItem)
return false;
// Compare internal models
return _internal.Equals(otherItem);
}
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(ModelBackedItem<Models.Metadata.DatItem>? other) public override bool Equals(ModelBackedItem<Models.Metadata.DatItem>? other)
{ {

View File

@@ -88,7 +88,7 @@ namespace SabreTools.DatItems.Formats
// Otherwise, treat it as a Blank // Otherwise, treat it as a Blank
Blank? newOther = other as Blank; Blank? newOther = other as Blank;
// If the archive information matches // If the machine information matches
return GetFieldValue<Machine>(DatItem.MachineKey) == newOther!.GetFieldValue<Machine>(DatItem.MachineKey); return GetFieldValue<Machine>(DatItem.MachineKey) == newOther!.GetFieldValue<Machine>(DatItem.MachineKey);
} }