2023-11-19 18:24:10 +08:00
|
|
|
|
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)
|
|
|
|
|
{
|
refactor(module: tree): Refactor tree's Selected/Checked/Expanded parameters (#3896)
* 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.
2024-06-05 00:26:31 +08:00
|
|
|
|
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))
|
2023-11-19 18:24:10 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|