Example #1
0
 /**
  * @return the number of evaluated cells in the range that match the specified criteria
  */
 private double CountMatchingCellsInArea(ValueEval rangeArg, IMatchPredicate 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 + ")");
     }
 }
Example #2
0
 public static int CountArg(ValueEval eval, IMatchPredicate 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);
 }
Example #3
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));
        }