mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-23 15:24:56 +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("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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user