You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
848 B
24 lines
848 B
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<double>(context, "value");
|
|
var digits = (int)ParameterExpression.Access<double>(context, "digits");
|
|
return Math.Round(value, digits);
|
|
}
|
|
}
|
|
}
|