You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/Plugins/Smart-Inspector/Runtime/Fluent UITK/FluentUITK.Utils.Bindings.cs

26 lines
827 B
C#

3 months ago
using System;
using System.Linq.Expressions;
namespace AV.UITK
{
public static partial class FluentUITK
{
/// <summary> Retrieves full path of a source member that can be used for binding. </summary>
public static string GetMemberPath<TSource>(Expression<Func<TSource, object>> expression)
{
var member = expression.Body as MemberExpression;
if (member == null)
{
var unary = expression.Body as UnaryExpression;
if (unary != null && unary.NodeType == ExpressionType.Convert)
member = unary.Operand as MemberExpression;
}
var result = member?.ToString();
result = result?.Substring(result.IndexOf('.') + 1);
return result;
}
}
}