api/NetinaCMS.Common/Extensions/PropertyExtensions.cs

16 lines
459 B
C#
Raw Permalink Normal View History

2024-03-09 19:53:01 +03:30
using System.Reflection;
2024-03-24 12:35:42 +03:30
namespace NetinaCMS.Common.Extensions
2024-03-09 19:53:01 +03:30
{
public static class PropertyExtensions
{
public static string GetPropertyDisplayName(this MemberInfo propertyExpression)
{
var memberInfo = propertyExpression;
var attr = memberInfo.GetCustomAttributes<DisplayAttribute>().FirstOrDefault();
if (attr == null) return memberInfo.Name;
return attr.Name;
}
}
}