mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 09:21:24 +08:00
3bf616b735
* refactor(module: table): Unify the behavior of Field and DataIndex * fix(module: table): Fix DataIndex Column doesn't refresh * doc(module: table): add DataIndex column filter demo * doc(module: table): fix Blazor table Co-authored-by: James Yeung <shunjiey@hotmail.com>
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Linq.Expressions;
|
|
using System.Reflection;
|
|
|
|
namespace AntDesign.Internal
|
|
{
|
|
internal static class ColumnExpressionHelper
|
|
{
|
|
internal static MemberInfo GetReturnMemberInfo(LambdaExpression expression)
|
|
{
|
|
var accessorBody = expression.Body;
|
|
|
|
if (accessorBody is UnaryExpression unaryExpression
|
|
&& unaryExpression.NodeType == ExpressionType.Convert
|
|
&& unaryExpression.Type == typeof(object))
|
|
{
|
|
accessorBody = unaryExpression.Operand;
|
|
}
|
|
|
|
if (accessorBody is ConditionalExpression conditionalExpression)
|
|
{
|
|
accessorBody = conditionalExpression.IfTrue;
|
|
}
|
|
|
|
if (!(accessorBody is MemberExpression memberExpression))
|
|
{
|
|
throw new ArgumentException($"The type of the provided expression {accessorBody.GetType().Name} is not supported, it should be {nameof(MemberExpression)}.");
|
|
}
|
|
|
|
return memberExpression.Member;
|
|
}
|
|
}
|
|
}
|