/** * @return the number of evaluated cells in the range that match the specified criteria */ private double CountMatchingCellsInArea(ValueEval rangeArg, I_MatchPredicate criteriaPredicate) { if (rangeArg is RefEval) { return(CountUtils.CountMatchingCell((RefEval)rangeArg, criteriaPredicate)); } else if (rangeArg is TwoDEval) { return(CountUtils.CountMatchingCellsInArea((TwoDEval)rangeArg, criteriaPredicate)); } else { throw new ArgumentException("Bad range arg type (" + rangeArg.GetType().Name + ")"); } }
public static int CountArg(ValueEval eval, I_MatchPredicate criteriaPredicate) { if (eval == null) { throw new ArgumentException("eval must not be null"); } if (eval is TwoDEval) { return(CountUtils.CountMatchingCellsInArea((TwoDEval)eval, criteriaPredicate)); } if (eval is RefEval) { return(CountUtils.CountMatchingCell((RefEval)eval, criteriaPredicate)); } return(criteriaPredicate.Matches(eval) ? 1 : 0); }
public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0) { double result; if (arg0 is RefEval) { result = CountUtils.CountMatchingCell((RefEval)arg0, predicate); } else if (arg0 is TwoDEval) { result = CountUtils.CountMatchingCellsInArea((TwoDEval)arg0, predicate); } else { throw new ArgumentException("Bad range arg type (" + arg0.GetType().Name + ")"); } return(new NumberEval(result)); }