Move ExpressionNodes to their own directory.

This commit is contained in:
2019-12-02 02:19:27 +01:00
parent d4dad30002
commit 99ca81a968
14 changed files with 13 additions and 13 deletions

View File

@@ -0,0 +1,30 @@
using System;
namespace VAR.ExpressionEvaluator
{
public class ExpressionNumberNegateNode : ExpressionUnaryNode
{
public ExpressionNumberNegateNode(IExpressionNode node) :
base(node, NumberNegateOp)
{
}
private static object NumberNegateOp(object value)
{
if (value is string)
{
if (decimal.TryParse((string)value, out decimal dec) == false)
{
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)value));
}
value = dec;
}
if ((value is decimal) == false)
{
throw new Exception("Can't negate non decimal values");
}
return -(decimal)value;
}
}
}