1234567891011121314151617181920212223242526272829303132333435 |
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using Luticate2.Auth.Utils.Business.Converters;
- using Luticate2.Auth.Utils.Dbo;
- using Luticate2.Auth.Utils.Dbo.Result;
- using Luticate2.Auth.Utils.Exceptions;
-
- namespace Luticate2.Auth.Utils.Business.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];
- }
- }
- }
|