Make "simple" metadata items equatable

This commit is contained in:
Matt Nadareski
2026-04-02 16:07:34 -04:00
parent 1e27b5d720
commit ca95e96402
13 changed files with 274 additions and 13 deletions

View File

@@ -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;
}
}
}