mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 17:31:42 +08:00
82ef62b7a7
* fix: add @commitlint/config-conventional to devDependencies * feat: add basic table implementation * feat: continue adding definitions * feat: end of work in 20200414 * fix: add readonly to csssizelength * fix: warnings from table * fix: add ignorecase to csssizelength * feat: refactor table * feat: add simple table Co-authored-by: ElderJames <shunjiey@hotmail.com>
25 lines
1015 B
C#
25 lines
1015 B
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Reflection;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
|
|
namespace AntDesign.Internal
|
|
{
|
|
internal static class DataAnnotationsExtensions
|
|
{
|
|
private static readonly ConcurrentDictionary<(Type ModelType, string FieldName), PropertyInfo> _propertyInfoCache = new ConcurrentDictionary<(Type, string), PropertyInfo>();
|
|
|
|
internal static bool TryGetValidateProperty(this FieldIdentifier fieldIdentifier, out PropertyInfo propertyInfo)
|
|
{
|
|
var cacheKey = (ModelType: fieldIdentifier.Model.GetType(), fieldIdentifier.FieldName);
|
|
propertyInfo = _propertyInfoCache.GetOrAdd(cacheKey, key => cacheKey.ModelType.GetProperty(cacheKey.FieldName));
|
|
return propertyInfo != null;
|
|
}
|
|
|
|
internal static PropertyInfo GetProperty(this FieldIdentifier fieldIdentifier)
|
|
{
|
|
return fieldIdentifier.TryGetValidateProperty(out var property) ? property : null;
|
|
}
|
|
}
|
|
}
|