Beispiel #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.CountMatchingCellsInRef((RefEval)rangeArg, criteriaPredicate));
     }
     else if (rangeArg is ThreeDEval)
     {
         return(CountUtils.CountMatchingCellsInArea((ThreeDEval)rangeArg, criteriaPredicate));
     }
     else
     {
         throw new ArgumentException("Bad range arg type (" + rangeArg.GetType().Name + ")");
     }
 }
Beispiel #2
0
        public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0)
        {
            double result;

            if (arg0 is RefEval)
            {
                result = CountUtils.CountMatchingCellsInRef((RefEval)arg0, predicate);
            }
            else if (arg0 is ThreeDEval)
            {
                result = CountUtils.CountMatchingCellsInArea((ThreeDEval)arg0, predicate);
            }
            else
            {
                throw new ArgumentException("Bad range arg type (" + arg0.GetType().Name + ")");
            }
            return(new NumberEval(result));
        }
Beispiel #3
0
 public static int CountArg(ValueEval eval, IMatchPredicate criteriaPredicate)
 {
     if (eval == null)
     {
         throw new ArgumentException("eval must not be null");
     }
     if (eval is ThreeDEval)
     {
         return(CountUtils.CountMatchingCellsInArea((ThreeDEval)eval, criteriaPredicate));
     }
     if (eval is TwoDEval)
     {
         throw new ArgumentException("Count requires 3D Evals, 2D ones aren't supported");
     }
     if (eval is RefEval)
     {
         return(CountUtils.CountMatchingCellsInRef((RefEval)eval, criteriaPredicate));
     }
     return(criteriaPredicate.Matches(eval) ? 1 : 0);
 }