mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-14 08:51:27 +08:00
de69cc5dd5
* fix(module:select): value no longer reset on datasource set * fix(module:select): dataSource change detection * fix: improve datasource detection add item & set value in SelectOption * tests: scenario from issue #1207 * fix: DataSourceEqualityComparer default
31 lines
917 B
C#
31 lines
917 B
C#
using System.Collections.Generic;
|
|
|
|
namespace AntDesign
|
|
{
|
|
internal class DataSourceEqualityComparer<TItemValue, TItem> : IEqualityComparer<TItem>
|
|
{
|
|
private Select<TItemValue, TItem> SelectParent { get; }
|
|
|
|
public DataSourceEqualityComparer(Select<TItemValue, TItem> selectParent)
|
|
{
|
|
SelectParent = selectParent;
|
|
}
|
|
|
|
public bool Equals(TItem x, TItem y)
|
|
{
|
|
if (SelectParent._getLabel is null)
|
|
{
|
|
return x.ToString().Equals(y.ToString())
|
|
&& SelectParent._getValue(x).Equals(SelectParent._getValue(y));
|
|
}
|
|
return SelectParent._getLabel(x).Equals(SelectParent._getLabel(y))
|
|
&& SelectParent._getValue(x).Equals(SelectParent._getValue(y));
|
|
}
|
|
|
|
public int GetHashCode(TItem obj)
|
|
{
|
|
return obj.GetHashCode();
|
|
}
|
|
}
|
|
}
|