mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 05:27:37 +08:00
b977e4e3ca
* refactor(module: tree): Refactor tree's Selected/Checked/Expanded parameters.(#2112,#2577,#2754,#2848,#3238,#3641,#3730,#3845,#3881,#3890,#3891,#3892) * Update the demo & document of tree & tree-select. * refactor(module: tree): Remove IsSelected/IsChecked/IsExpanded.
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Microsoft.AspNetCore.Components
|
|
{
|
|
public static class ParameterViewExtensions
|
|
{
|
|
public static bool IsParameterChanged<T>(this ParameterView parameters,
|
|
string parameterName, T value)
|
|
{
|
|
return IsParameterChanged(parameters, parameterName, value, out _);
|
|
}
|
|
|
|
public static bool IsParameterChanged<T>(this ParameterView parameters,
|
|
string parameterName, T value, out T newValue)
|
|
{
|
|
if (parameters.TryGetValue(parameterName, out newValue))
|
|
{
|
|
if (newValue == null && value == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (newValue == null && value != null)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (newValue != null && value == null)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (newValue is string[] stringNewValue && value is string[] stringValue)
|
|
{
|
|
return !stringNewValue.SequenceEqual(stringValue);
|
|
}
|
|
|
|
if (!EqualityComparer<T>.Default.Equals(value, newValue))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|