Handle nested item comparisons, add Equals tests

This commit is contained in:
Matt Nadareski
2025-01-08 11:36:43 -05:00
parent 8cf360a747
commit 5b430804d7
12 changed files with 501 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
using SabreTools.Core.Tools;
// TODO: Add item mappings for all fields
@@ -192,6 +193,36 @@ namespace SabreTools.DatItems.Formats
#region Comparision Methods
/// <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 Equals(otherItem);
}
/// <inheritdoc/>
public override bool Equals(ModelBackedItem<Models.Metadata.DatItem>? 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 Equals(otherItem);
}
/// <inheritdoc/>
public override bool Equals(DatItem? other)
{