refactor: 调整文件位置

This commit is contained in:
Argo-Cloud 2020-12-25 01:49:15 +08:00
parent 7762b36e37
commit 531cafc11c
46 changed files with 0 additions and 37 deletions

View File

@ -1,37 +0,0 @@
using Bootstrap.Admin.Pages.Components;
using Microsoft.Extensions.DependencyInjection;
using System.ComponentModel;
namespace Microsoft.AspNetCore.Components.Forms
{
/// <summary>
///
/// </summary>
public static class FieldIdentifierExtensions
{
/// <summary>
///
/// </summary>
/// <param name="fieldIdentifier"></param>
/// <returns></returns>
public static string GetDisplayName(this FieldIdentifier fieldIdentifier)
{
var cacheKey = (Type: fieldIdentifier.Model.GetType(), FieldName: fieldIdentifier.FieldName);
if (!DisplayNamesExtensions.TryGetValue(cacheKey, out var dn))
{
if (BootstrapAdminEditContextDataAnnotationsExtensions.TryGetValidatableProperty(fieldIdentifier, out var propertyInfo))
{
var displayNameAttribute = propertyInfo.GetCustomAttributes(typeof(DisplayNameAttribute), true);
if (displayNameAttribute.Length > 0)
{
dn = ((DisplayNameAttribute)displayNameAttribute[0]).DisplayName;
// add display name into cache
DisplayNamesExtensions.GetOrAdd((fieldIdentifier.Model.GetType(), fieldIdentifier.FieldName), key => dn);
}
}
}
return dn ?? cacheKey.FieldName;
}
}
}