27 lines
633 B
C#
27 lines
633 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace WalkingTec.Mvvm.Core
|
|
{
|
|
public class CommonEqualityComparer<T, V> : IEqualityComparer<T>
|
|
{
|
|
private Func<T, V> keySelector;
|
|
|
|
public CommonEqualityComparer(Func<T, V> keySelector)
|
|
{
|
|
this.keySelector = keySelector;
|
|
}
|
|
|
|
public bool Equals(T x, T y)
|
|
{
|
|
return EqualityComparer<V>.Default.Equals(keySelector(x), keySelector(y));
|
|
}
|
|
|
|
public int GetHashCode(T obj)
|
|
{
|
|
return EqualityComparer<V>.Default.GetHashCode(keySelector(obj));
|
|
}
|
|
}
|
|
}
|