public bool Compare(TypedValue actual, Tree <Cell> expected) { object actualValue = actual.Value; Cell cell = expected.Value; Comparison comparison = FindComparison(cell.Text); var rest = new CellSubstring(cell, cell.Text.Substring(comparison.Operator.Length)); object expectedValue = Processor.Parse(actual.Type, rest).Value; expected.Value.SetAttribute(CellAttribute.InformationPrefix, actualValue.ToString()); int compare = actualValue is float || actualValue is double ?(Convert.ToDouble(actualValue) < Convert.ToDouble(expectedValue) ? -1 : (Convert.ToDouble(actualValue) > Convert.ToDouble(expectedValue) ? 1 : 0)) : decimal.Compare(Convert.ToDecimal(actualValue), Convert.ToDecimal(expectedValue)); return(comparison.MinCompare <= compare && compare <= comparison.MaxCompare); }
public TypedValue Parse(Type type, TypedValue instance, Tree <Cell> parameters) { Cell cell = parameters.Value; int daysToAdd = 0; if (cell.Text.Length > today.Length) { string modifier = cell.Text.Substring(today.Length).Trim(); var rest = new CellSubstring(cell, modifier.Substring(1)); daysToAdd = Processor.Parse <Cell, int>(rest); if (modifier.StartsWith("-")) { daysToAdd = -daysToAdd; } } DateTime resultDate = DateTime.Now.Date.AddDays(daysToAdd); return(new TypedValue(resultDate)); }