Exemplo n.º 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 + ")");
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
        }
Exemplo n.º 4
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);
 }