mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00
29 lines
791 B
C#
29 lines
791 B
C#
namespace Spectre.Console.Cli;
|
|
|
|
internal static class CommandParameterComparer
|
|
{
|
|
public static readonly ByBackingPropertyComparer ByBackingProperty = new ByBackingPropertyComparer();
|
|
|
|
public sealed class ByBackingPropertyComparer : IEqualityComparer<CommandParameter?>
|
|
{
|
|
public bool Equals(CommandParameter? x, CommandParameter? y)
|
|
{
|
|
if (x is null || y is null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (ReferenceEquals(x, y))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return x.Property.MetadataToken == y.Property.MetadataToken;
|
|
}
|
|
|
|
public int GetHashCode(CommandParameter? obj)
|
|
{
|
|
return obj?.Property?.MetadataToken.GetHashCode() ?? 0;
|
|
}
|
|
}
|
|
} |