summaryrefslogtreecommitdiff
path: root/Juick/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Classes')
-rw-r--r--Juick/Classes/ExpressionHelper.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/Juick/Classes/ExpressionHelper.cs b/Juick/Classes/ExpressionHelper.cs
new file mode 100644
index 0000000..3eb453a
--- /dev/null
+++ b/Juick/Classes/ExpressionHelper.cs
@@ -0,0 +1,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;
+ }
+ }
+}