mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
Default sort is never done, so CompareTo is useless
This commit is contained in:
@@ -52,7 +52,7 @@ namespace SabreTools.Metadata.DatItems
|
||||
[XmlInclude(typeof(SoftwareList))]
|
||||
[XmlInclude(typeof(Sound))]
|
||||
[XmlInclude(typeof(SourceDetails))]
|
||||
public abstract class DatItem : ICloneable, IComparable<DatItem>, IEquatable<DatItem>
|
||||
public abstract class DatItem : ICloneable, IEquatable<DatItem>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -137,26 +137,6 @@ namespace SabreTools.Metadata.DatItems
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int CompareTo(DatItem? other)
|
||||
{
|
||||
// If the other item doesn't exist
|
||||
if (other is null)
|
||||
return 1;
|
||||
|
||||
// Get the names to avoid changing values
|
||||
string? selfName = GetName();
|
||||
string? otherName = other.GetName();
|
||||
|
||||
// If the names are equal
|
||||
if (selfName == otherName)
|
||||
return Equals(other) ? 0 : 1;
|
||||
|
||||
// If `otherName` is null, Compare will return > 0
|
||||
// If `selfName` is null, Compare will return < 0
|
||||
return string.Compare(selfName, otherName, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if an item is a duplicate using partial matching logic
|
||||
/// </summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SabreTools.Metadata.DatItems
|
||||
/// <summary>
|
||||
/// Base class for all items included in a set that are backed by an internal model
|
||||
/// </summary>
|
||||
public abstract class DatItem<T> : DatItem, IEquatable<DatItem<T>>, IComparable<DatItem<T>>, ICloneable
|
||||
public abstract class DatItem<T> : DatItem, ICloneable, IEquatable<DatItem<T>>
|
||||
where T : Data.Models.Metadata.DatItem, new()
|
||||
{
|
||||
#region Private Fields
|
||||
@@ -54,26 +54,6 @@ namespace SabreTools.Metadata.DatItems
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int CompareTo(DatItem<T>? other)
|
||||
{
|
||||
// If the other item doesn't exist
|
||||
if (other is null)
|
||||
return 1;
|
||||
|
||||
// Get the names to avoid changing values
|
||||
string? selfName = GetName();
|
||||
string? otherName = other.GetName();
|
||||
|
||||
// If the names are equal
|
||||
if (selfName == otherName)
|
||||
return Equals(other) ? 0 : 1;
|
||||
|
||||
// If `otherName` is null, Compare will return > 0
|
||||
// If `selfName` is null, Compare will return < 0
|
||||
return string.Compare(selfName, otherName, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if an item is a duplicate using partial matching logic
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user