refactor: 未设置 DisplayName 时显示字段名

This commit is contained in:
Argo Zhang 2020-02-04 16:02:21 +08:00
parent 667e482687
commit 4202871c29
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 2 additions and 2 deletions

View File

@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Components.Forms
/// <returns></returns> /// <returns></returns>
public static string GetDisplayName(this FieldIdentifier fieldIdentifier) public static string GetDisplayName(this FieldIdentifier fieldIdentifier)
{ {
var cacheKey = (fieldIdentifier.Model.GetType(), fieldIdentifier.FieldName); var cacheKey = (Type: fieldIdentifier.Model.GetType(), FieldName: fieldIdentifier.FieldName);
if (!DisplayNamesExtensions.TryGetValue(cacheKey, out var dn)) if (!DisplayNamesExtensions.TryGetValue(cacheKey, out var dn))
{ {
if (BootstrapAdminEditContextDataAnnotationsExtensions.TryGetValidatableProperty(fieldIdentifier, out var propertyInfo)) if (BootstrapAdminEditContextDataAnnotationsExtensions.TryGetValidatableProperty(fieldIdentifier, out var propertyInfo))
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Components.Forms
} }
} }
} }
return dn ?? "未设置"; return dn ?? cacheKey.FieldName;
} }
} }
} }