blob: 3eb453ad040b8f5d011658159d64b8dcd221470a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
using System;
using System.Linq.Expressions;
namespace Juick.Classes
{
static class ExpressionHelper
{
public static string GetPropertyName<T>(Expression<Func<T, object>> propertyExpression)
{
var bodyExpression = propertyExpression.Body;
var unaryExpression = bodyExpression as UnaryExpression;
if (unaryExpression != null)
{
bodyExpression = unaryExpression.Operand;
}
var memberExpression = (MemberExpression)bodyExpression;
return memberExpression.Member.Name;
}
}
}
|