Api/NetinaShop.Common/Extensions/PropertyExtensions.cs

16 lines
460 B
C#
Raw Normal View History

using System.Reflection;
2023-12-16 20:25:12 +03:30
namespace NetinaShop.Common.Extensions
{
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;
}
}
}