12345678910111213141516171819202122232425262728293031323334 |
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using Luticate2.Auth.Utils.Dbo;
- using Luticate2.Auth.Utils.Dbo.Result;
- using Luticate2.Auth.Utils.Exceptions;
-
- namespace Luticate2.Auth.Utils.Business.Converters.ExpressionConverter
- {
- public interface ILuExpressionParamReplaceVisitorOptions
- {
- IDictionary<ParameterExpression, Expression> Parameters { get; }
- }
-
- public class LuExpressionParamReplaceVisitor : ExpressionVisitor
- {
- public ILuExpressionParamReplaceVisitorOptions Options { get; }
-
- public LuExpressionParamReplaceVisitor(ILuExpressionParamReplaceVisitorOptions options)
- {
- Options = options;
- }
-
- protected override Expression VisitParameter(ParameterExpression node)
- {
- if (!Options.Parameters.ContainsKey(node))
- {
- LuResult<Expression>.Error(LuStatus.InternalError.ToInt(),
- $"Could not find a conversion for parameter {node}").Throw();
- }
-
- return Options.Parameters[node];
- }
- }
- }
|