1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using Luticate2.Auth.Dbo.Result;
-
- namespace Luticate2.Auth.Business.Fields.DMEC
- {
- public class LuExpressionConverterIdentity<TType> : LuExpressionConverter<TType, TType>
- {
- public LuExpressionConverterIdentity(IServiceProvider serviceProvider) : base(serviceProvider)
- {
- }
-
- protected override LuResult<Expression> ConvertInternal(Stack<Expression> 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<Expression>();
- 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);
- }
- }
- }
|