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
828 B
24 lines
828 B
2 years ago
|
using EC.Helper.RabbitFunc.Expressions;
|
||
|
using EC.Helper.RabbitFunc.Runtime;
|
||
|
|
||
|
namespace EC.Helper.RabbitFunc.Extern;
|
||
|
|
||
|
[ExternLambda]
|
||
|
internal class MaxLambdaExpression : SystemLambdaExpression
|
||
|
{
|
||
|
public MaxLambdaExpression()
|
||
|
: base(typeof(Math).GetMethod(nameof(Math.Max), new Type[] { typeof(double), typeof(double) }), "max", new BodyExpression(),
|
||
|
Expression.Parameter(typeof(double), "left"),
|
||
|
Expression.Parameter(typeof(double), "right"))
|
||
|
{ }
|
||
|
|
||
|
private class BodyExpression : Expression
|
||
|
{
|
||
|
public override object Eval(RuntimeContext context)
|
||
|
{
|
||
|
var left = ParameterExpression.Access<double>(context, "left");
|
||
|
var right = ParameterExpression.Access<double>(context, "right");
|
||
|
return Math.Max(left, right);
|
||
|
}
|
||
|
}
|
||
|
}
|