static string DoCalcution(string warewolfAtomToString)
{
if(warewolfAtomToString == null)
{
return null;
}
string cleanExpression;
var isCalcEvaluation = DataListUtil.IsCalcEvaluation(warewolfAtomToString, out cleanExpression);
if (isCalcEvaluation)
{
var functionEvaluator = new FunctionEvaluator();
string eval;
string error;
var tryEvaluateFunction = functionEvaluator.TryEvaluateFunction(cleanExpression, out eval, out error);
warewolfAtomToString = eval;
if (eval == cleanExpression.Replace("\"", "") && cleanExpression.Contains("\""))
{
try
{
string eval2;
var b = functionEvaluator.TryEvaluateFunction(cleanExpression.Replace("\"", ""), out eval2, out error);
if (b)
{
warewolfAtomToString = eval2;
}
}
catch (Exception err)
{
Dev2Logger.Log.Warn(err);
}
}
if (!tryEvaluateFunction)
{
if (error == "Incorrect type of argument or operand.")
error += string.Format(" Unable to calculate: '{0}'. Try rewriting the expression.", cleanExpression);
throw new Exception(error);
}
}
return warewolfAtomToString;
}