17 lines
505 B
C#
17 lines
505 B
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Reflection;
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |