public bool Evaluate(object left, string expression)
{
var operatorCandidate = GetNonNumericStartChars(expression);
var leftNum = OperandAsDouble(left);
if (!string.IsNullOrEmpty(operatorCandidate) && leftNum != null)
{
IOperator op;
if (OperatorsDict.Instance.TryGetValue(operatorCandidate, out op))
{
var numericCandidate = expression.Replace(operatorCandidate, string.Empty);
double d;
if (double.TryParse(numericCandidate, out d))
{
var leftResult = _compileResultFactory.Create(leftNum);
var rightResult = _compileResultFactory.Create(d);
var result = op.Apply(leftResult, rightResult);
if (result.DataType != DataType.Boolean)
{
throw new ArgumentException("Illegal operator in expression");
}
return (bool)result.Result;
}
}
}
return _valueMatcher.IsMatch(left, expression) == 0;
}