Files
certmgr/certmgr/Certificates/CertGen/Utils/CollectionEquivalencyComparer.cs
2025-11-02 18:32:52 +01:00

27 lines
599 B
C#

using CertMgr.Core.Utils;
namespace CertMgr.Certificates.CertGen.Utils;
public sealed class CollectionEquivalencyComparer<T> : IEqualityComparer<IEnumerable<T>> where T : notnull
{
public bool Equals(IEnumerable<T>? x, IEnumerable<T>? y)
{
if (x == y)
{
return true;
}
if (x == null || y == null)
{
return false;
}
bool equivalent = x.Equivalent(y);
return equivalent;
}
public int GetHashCode(IEnumerable<T> obj)
{
return obj?.Sum(it => it?.GetHashCode() ?? 0) ?? 0;
}
}