public static UnaryExpression Negate(Expression expression, MethodInfo method)
{
RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic() && !expression.Type.IsUnsignedInt())
{
return new UnaryExpression(ExpressionType.Negate, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Negate, "op_UnaryNegation", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Negate, expression, method);
}