ant-design-blazor/components/core/HashCodes/HashCode.cs
老九 b1bbe30323 perf(module: table): use hash-code comparison for all the parameters to control UI rendering (#716)
* 为组件增加GetParametersHashCode()扩展方法,以支持控制组件的渲染方式;
为Table组件增加RenderMode的渲染模式参数;

* fix: translate the comments

Co-authored-by: ElderJames <shunjiey@hotmail.com>
2020-10-25 18:31:31 +08:00

33 lines
1.1 KiB
C#

namespace AntDesign.Core.HashCodes
{
/// <summary>
/// Provides a hash comparison of two parameter values
/// </summary>
/// <typeparam name="TParameter"></typeparam>
static class HashCode<TParameter>
{
private static readonly HashCodeProvider _provider = HashCodeProvider.Create(typeof(TParameter));
/// <summary>
/// Calculate whether the hash of two parameter values is equal
/// </summary>
/// <param name="parameter1">Parameter 1</param>
/// <param name="parameter2">Parameter 2</param>
/// <returns></returns>
public static bool HashCodeEquals(TParameter parameter1, TParameter parameter2)
{
return GetHashCode(parameter1) == GetHashCode(parameter2);
}
/// <summary>
/// Calculate the hash value of the parameter
/// </summary>
/// <param name="parameter">Parameter</param>
/// <returns></returns>
public static int GetHashCode(TParameter parameter)
{
return _provider.GetHashCode(parameter);
}
}
}