!1944 feat(#I4D8DL): model support MedadataTypeAttribute on TableColumn component

* chore: bump version to 5.14.5
* feat: 读取模型标签支持 MedadataType 方式
This commit is contained in:
Argo
2021-10-10 16:08:30 +00:00
parent 7142550a90
commit 8fffd92f5f
2 changed files with 6 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>5.14.4</Version>
<Version>5.14.5</Version>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

View File

@@ -148,8 +148,12 @@ namespace BootstrapBlazor.Components
var cacheKey = (ModelType: modelType, FieldName: fieldName);
if (!PropertyInfoCache.TryGetValue(cacheKey, out propertyInfo))
{
// 支持 MetadataType
var metadataType = modelType.GetCustomAttribute<MetadataTypeAttribute>(false);
// Validator.TryValidateProperty 只能对 Public 属性生效
propertyInfo = cacheKey.ModelType.GetProperties().Where(x => x.Name == cacheKey.FieldName).FirstOrDefault();
propertyInfo = metadataType?.MetadataClassType.GetProperties().Where(x => x.Name == cacheKey.FieldName).FirstOrDefault()
?? cacheKey.ModelType.GetProperties().Where(x => x.Name == cacheKey.FieldName).FirstOrDefault();
if (propertyInfo != null)
{