Make virtual DatItem.Equals easier to read

This commit is contained in:
Matt Nadareski
2025-01-07 16:43:33 -05:00
parent d4b16acd35
commit 3196c69d8e

View File

@@ -559,8 +559,16 @@ namespace SabreTools.DatItems
/// <returns>True if the items are duplicates, false otherwise</returns> /// <returns>True if the items are duplicates, false otherwise</returns>
public virtual bool Equals(DatItem<T>? other) public virtual bool Equals(DatItem<T>? other)
{ {
// If the other value is null
if (other == null)
return false;
// Get the types for comparison
ItemType selfType = GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>();
ItemType otherType = other.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>();
// If we don't have a matched type, return false // If we don't have a matched type, return false
if (GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>() != other?.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>()) if (selfType != otherType)
return false; return false;
// Compare the internal models // Compare the internal models