DefaultCharComparer
using System;
using System.Diagnostics.CodeAnalysis;
namespace DotNext
{
internal sealed class DefaultCharComparer : CharComparer
{
private readonly StringComparison comparisonType;
internal DefaultCharComparer(StringComparison comparison)
{
comparisonType = comparison;
}
public override bool Equals(char x, char y)
{
return CharComparer.Equals(x, y, comparisonType);
}
public override int Compare(char x, char y)
{
return CharComparer.Compare(x, y, comparisonType);
}
public override int GetHashCode(char ch)
{
return CharComparer.GetHashCode(ch, comparisonType);
}
public override bool Equals([NotNullWhen(true)] object other)
{
DefaultCharComparer defaultCharComparer = other as DefaultCharComparer;
if (defaultCharComparer != null)
return comparisonType == defaultCharComparer.comparisonType;
return false;
}
public override int GetHashCode()
{
return (int)comparisonType;
}
public override string ToString()
{
return comparisonType.ToString();
}
}
}