mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 17:31:42 +08:00
28 lines
907 B
C#
28 lines
907 B
C#
|
using Microsoft.AspNetCore.Components;
|
|||
|
|
|||
|
namespace AntDesign.Core.HashCodes
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Provide HashCode calculation of component parameters and other functions
|
|||
|
/// </summary>
|
|||
|
static class HashCodeExtensions
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Compute the HashCode for all parameters
|
|||
|
/// </summary>
|
|||
|
/// <typeparam name="TComponent"></typeparam>
|
|||
|
/// <param name="component">Component</param>
|
|||
|
/// <returns></returns>
|
|||
|
public static int GetParametersHashCode<TComponent>(this TComponent component) where TComponent : ComponentBase
|
|||
|
{
|
|||
|
var hashCode = 0;
|
|||
|
var descriptors = ParameterDescriptor<TComponent>.Descriptors;
|
|||
|
foreach (var descriptor in descriptors)
|
|||
|
{
|
|||
|
hashCode ^= descriptor.GetValueHashCode(component);
|
|||
|
}
|
|||
|
return hashCode;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|