28 lines
779 B
C#
28 lines
779 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ZicMoove.Helpers
|
|
{
|
|
public static class PropertySupport
|
|
{
|
|
public static string ExtractPropertyName<T>(Expression<Func<T>> propertyExpression)
|
|
{
|
|
if (propertyExpression == null)
|
|
{
|
|
throw new ArgumentNullException("propertyExpression");
|
|
}
|
|
|
|
var memberExpression = propertyExpression.Body as MemberExpression;
|
|
if (memberExpression == null)
|
|
{
|
|
throw new ArgumentException("Invalide Expression", "propertyExpression");
|
|
}
|
|
return memberExpression.Member.Name;
|
|
}
|
|
}
|
|
}
|