using System; using System.Collections.Generic; using System.Linq.Expressions; using Luticate2.Auth.Dbo.Result; namespace Luticate2.Auth.Business.Fields.DMEC { public class LuExpressionConverterIdentity : LuExpressionConverter { public LuExpressionConverterIdentity(IServiceProvider serviceProvider) : base(serviceProvider) { } protected override LuResult ConvertInternal(Stack expressions, Expression baseExpression, LuExpressionConverterOptions options) { var expression = expressions.Pop(); if (expression is MemberExpression memberExpression) { var newExpression = Expression.MakeMemberAccess(baseExpression, memberExpression.Member); return ConvertOther(newExpression.Type, expressions, newExpression, options); } else if (expression is MethodCallExpression methodCallExpression) { var argumentsModel = new List(); foreach (var argumentDbo in methodCallExpression.Arguments) { var converter = new LuExpressionConverterVisitor(options, ServiceProvider); var result = converter.Visit(argumentDbo); argumentsModel.Add(result); } var newExpression = Expression.Call(baseExpression, methodCallExpression.Method, argumentsModel); return ConvertOther(newExpression.Type, expressions, newExpression, options); } return base.ConvertInternal(expressions, baseExpression, options); } } }