예제 #1
0
 private ValueEval _evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex)
 {
     if (args.Length < 2)
     {
         return(ErrorEval.VALUE_INVALID);
     }
     LookupUtils.MatchMode matchMode = LookupUtils.MatchMode.ExactMatch;
     if (args.Length > 2)
     {
         try
         {
             ValueEval matchModeValue = OperandResolver.GetSingleValue(args[2], srcRowIndex, srcColumnIndex);
             int       matchInt       = OperandResolver.CoerceValueToInt(matchModeValue);
             matchMode = LookupUtils.GetMatchMode(matchInt);
         }
         catch (EvaluationException e)
         {
             return(e.GetErrorEval());
         }
         catch (Exception e)
         {
             return(ErrorEval.VALUE_INVALID);
         }
     }
     LookupUtils.SearchMode searchMode = LookupUtils.SearchMode.IterateForward;
     if (args.Length > 3)
     {
         try
         {
             ValueEval searchModeValue = OperandResolver.GetSingleValue(args[3], srcRowIndex, srcColumnIndex);
             int       searchInt       = OperandResolver.CoerceValueToInt(searchModeValue);
             searchMode = LookupUtils.GetSearchMode(searchInt);
         }
         catch (EvaluationException e)
         {
             return(e.GetErrorEval());
         }
         catch (Exception e)
         {
             return(ErrorEval.VALUE_INVALID);
         }
     }
     return(evaluate(srcRowIndex, srcColumnIndex, args[0], args[1], matchMode, searchMode));
 }
예제 #2
0
        private ValueEval _evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex, bool isSingleValue)
        {
            if (args.Length < 3)
            {
                return(ErrorEval.VALUE_INVALID);
            }
            String notFound = null;

            if (args.Length > 3)
            {
                try
                {
                    ValueEval notFoundValue = OperandResolver.GetSingleValue(args[3], srcRowIndex, srcColumnIndex);
                    String    notFoundText  = LaxValueToString(notFoundValue);
                    if (notFoundText != null)
                    {
                        String trimmedText = notFoundText.Trim();
                        if (trimmedText.Length > 0)
                        {
                            notFound = trimmedText;
                        }
                    }
                }
                catch (EvaluationException e)
                {
                    return(e.GetErrorEval());
                }
            }
            LookupUtils.MatchMode matchMode = LookupUtils.MatchMode.ExactMatch;
            if (args.Length > 4)
            {
                try
                {
                    ValueEval matchModeValue = OperandResolver.GetSingleValue(args[4], srcRowIndex, srcColumnIndex);
                    int       matchInt       = OperandResolver.CoerceValueToInt(matchModeValue);
                    matchMode = LookupUtils.GetMatchMode(matchInt);
                }
                catch (EvaluationException e)
                {
                    return(e.GetErrorEval());
                }
                catch (Exception)
                {
                    return(ErrorEval.VALUE_INVALID);
                }
            }
            LookupUtils.SearchMode searchMode = LookupUtils.SearchMode.IterateForward;
            if (args.Length > 5)
            {
                try
                {
                    ValueEval searchModeValue = OperandResolver.GetSingleValue(args[5], srcRowIndex, srcColumnIndex);
                    int       searchInt       = OperandResolver.CoerceValueToInt(searchModeValue);
                    searchMode = LookupUtils.GetSearchMode(searchInt);
                }
                catch (EvaluationException e)
                {
                    return(e.GetErrorEval());
                }
                catch (Exception)
                {
                    return(ErrorEval.VALUE_INVALID);
                }
            }
            return(evaluate(srcRowIndex, srcColumnIndex, args[0], args[1], args[2], notFound, matchMode, searchMode, isSingleValue));
        }