override public object Eval(DataRow row) { object obj1 = expr1.Eval(row); if (obj1 == DBNull.Value || obj1 == null) { return(obj1); } object obj2 = expr2.Eval(row); if (obj2 == DBNull.Value || obj2 == null) { return(obj2); } if (op == Operation.ADD && (obj1 is string || obj2 is string)) { return(obj1.ToString() + obj2.ToString()); } IConvertible o1 = (IConvertible)obj1; IConvertible o2 = (IConvertible)obj2; switch (op) { case Operation.ADD: return(Numeric.Add(o1, o2)); case Operation.SUB: return(Numeric.Subtract(o1, o2)); case Operation.MUL: return(Numeric.Multiply(o1, o2)); case Operation.DIV: return(Numeric.Divide(o1, o2)); case Operation.MOD: return(Numeric.Modulo(o1, o2)); default: return(0); } }
private void Aggregate(IConvertible val) { switch (function) { case AggregationFunction.Min: result = (result != null ? Numeric.Min(result, val) : val); return; case AggregationFunction.Max: result = (result != null ? Numeric.Max(result, val) : val); return; case AggregationFunction.Sum: case AggregationFunction.Avg: case AggregationFunction.StDev: case AggregationFunction.Var: result = (result != null ? Numeric.Add(result, val) : val); return; } }