using EC.Helper.RabbitFunc.Expressions; using EC.Helper.RabbitFunc.Runtime; namespace EC.Helper.RabbitFunc.Extern; [ExternLambda] internal class RoundLambdaExpression : SystemLambdaExpression { public RoundLambdaExpression() : base(typeof(Math).GetMethod(nameof(Math.Round), new Type[] { typeof(double), typeof(int) }), "round", new BodyExpression(), Expression.Parameter(typeof(double), "value"), Expression.Parameter(typeof(double), "digits")) { } private class BodyExpression : Expression { public override object Eval(RuntimeContext context) { var value = ParameterExpression.Access(context, "value"); var digits = (int)ParameterExpression.Access(context, "digits"); return Math.Round(value, digits); } } }