-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.cs
37 lines (32 loc) · 1.03 KB
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace RoboUI
{
internal static class Utils
{
internal static string GetFullPropertyName<TElement, TValue>(Expression<Func<TElement, TValue>> expression)
{
MemberExpression me;
switch (expression.Body.NodeType)
{
case ExpressionType.Convert:
case ExpressionType.ConvertChecked:
var ue = expression.Body as UnaryExpression;
me = ((ue != null) ? ue.Operand : null) as MemberExpression;
break;
default:
me = expression.Body as MemberExpression;
break;
}
var names = new List<string>();
while (me != null)
{
names.Add(me.Member.Name);
me = me.Expression as MemberExpression;
}
names.Reverse();
return string.Join(".", names);
}
}
}