src/Mimp.SeeSharper.Reflection.Expression/FuncExtensions.cs
/// <summary>
/// Try to resolve <paramref name="memberAccessor"/> to a <see cref="MemberExpression"/>.
/// </summary>
/// <typeparam name="TInstance"></typeparam>
/// <typeparam name="TMember"></typeparam>
/// <param name="memberAccessor"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="InvalidOperationException">If can't resolve it.</exception>
Try to resolve  to a .
Try to resolve to a .
public static MemberExpression ResolveMemberAccessor<TInstance, TMember>(this Func<TInstance, TMember> memberAccessor)
        {
            if (memberAccessor is null)
                throw new ArgumentNullException(nameof(memberAccessor));
            Expression<Func<TInstance, TMember>> e = t => memberAccessor(t);
            if (e.Body is InvocationExpression i)
                if (i.Expression is MemberExpression m)
                    return m;
            throw new InvalidOperationException($"Can't resolve function as {nameof(MemberExpression)}");
        }
public static MemberExpression ResolveMemberAccessor < TInstance , TMember > ( this Func < TInstance , TMember > memberAccessor ) { if ( memberAccessor is null ) throw new ArgumentNullException ( nameof ( memberAccessor ) ) ; Expression < Func < TInstance , TMember > > e = t => memberAccessor ( t ) ; if ( e . Body is InvocationExpression i ) if ( i . Expression is MemberExpression m ) return m ; throw new InvalidOperationException ( $" Can't resolve function as  { nameof ( MemberExpression ) } " ) ; }
Try to resolve  to a .
Try to resolve to a .
None
None
If can't resolve it.
If can ' t resolve it .
Func<TInstance, TMember>
this
memberAccessor
None
typeparam
None
typeparam
None