当前位置: 首页>>代码示例>>C#>>正文


C# Eval类代码示例

本文整理汇总了C#中Eval的典型用法代码示例。如果您正苦于以下问题:C# Eval类的具体用法?C# Eval怎么用?C# Eval使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Eval类属于命名空间,在下文中一共展示了Eval类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Evaluate

        public Eval Evaluate(Eval[] args, int srcCellRow, short srcCellCol)
        {
            switch (args.Length)
            {
                default:
                    return ErrorEval.VALUE_INVALID;
                case 1:
                    break;
            }
            Eval arg = args[0];
            if (arg is RefEval)
            {
                RefEval re = (RefEval)arg;
                arg = re.InnerValueEval;
            }

            if (arg is StringEval)
            {
                // Text values are returned Unmodified
                return arg;
            }

            if (arg is ErrorEval)
            {
                // Error values also returned Unmodified
                return arg;
            }
            // for all other argument types the result Is empty string
            return StringEval.EMPTY_INSTANCE;
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:30,代码来源:T.cs

示例2: EvaluateFunc

        public override ValueEval EvaluateFunc(Eval[] args, int srcCellRow, short srcCellCol)
        {
            if (args.Length != 3)
            {
                return ErrorEval.VALUE_INVALID;
            }

            String text = EvaluateStringArg(args[0], srcCellRow, srcCellCol);
            int startCharNum = EvaluateIntArg(args[1], srcCellRow, srcCellCol);
            int numChars = EvaluateIntArg(args[2], srcCellRow, srcCellCol);
            int startIx = startCharNum - 1; // convert to zero-based

            // Note - for start_num arg, blank/zero causes error(#VALUE!),
            // but for num_chars causes empty string to be returned.
            if (startIx < 0)
            {
                return ErrorEval.VALUE_INVALID;
            }
            if (numChars < 0)
            {
                return ErrorEval.VALUE_INVALID;
            }
            int len = text.Length;
            if (numChars < 0 || startIx > len)
            {
                return new StringEval("");
            }
            int endIx = Math.Min(startIx + numChars, len);
            String result = text.Substring(startIx, endIx-startIx);
            return new StringEval(result);
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:31,代码来源:Mid.cs

示例3: EvaluateAsInteger

 protected int EvaluateAsInteger(Eval eval)
 {
     int numval = -1;
     if (eval is NumberEval)
     {
         NumberEval neval = (NumberEval)eval;
         double d = neval.NumberValue;
         numval = (int)d;
     }
     else if (eval is StringEval)
     {
         StringEval seval = (StringEval)eval;
         String s = seval.StringValue;
         try
         {
             double d = double.Parse(s);
             numval = (int)d;
         }
         catch (Exception)
         {
         }
     }
     else if (eval is BoolEval)
     {
         BoolEval beval = (BoolEval)eval;
         numval = beval.BooleanValue ? 1 : 0;
     }
     else if (eval is RefEval)
     {
         numval = EvaluateAsInteger(XlateRefEval((RefEval)eval));
     }
     return numval;
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:33,代码来源:Right.cs

示例4: Evaluate

        public override Eval Evaluate(Eval[] operands, int srcCellRow, short srcCellCol)
        {
            Eval retval = BoolEval.FALSE;

            switch (operands.Length)
            {
                case 1:
                    Eval eval = operands[0];
                    if (eval is BoolEval)
                    {
                        retval = BoolEval.TRUE;
                    }
                    else if (eval is RefEval)
                    {
                        Eval xlatedEval = XlateRefEval((RefEval)eval);
                        if (xlatedEval is BoolEval)
                        {
                            retval = BoolEval.TRUE;
                        }
                    }
                    break;
                default:
                    retval = ErrorEval.VALUE_INVALID;
                    break;

            }

            return retval;
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:29,代码来源:Islogical.cs

示例5: GetSingleValue

 /**
  * Retrieves a single value from a variety of different argument types according to standard
  * Excel rules.  Does not perform any type conversion.
  * @param arg the Evaluated argument as passed to the function or operator.
  * @param srcCellRow used when arg Is a single column AreaRef
  * @param srcCellCol used when arg Is a single row AreaRef
  * @return a <tt>NumberEval</tt>, <tt>StringEval</tt>, <tt>BoolEval</tt> or <tt>BlankEval</tt>.
  * Never <c>null</c> or <tt>ErrorEval</tt>.
  * @throws EvaluationException(#VALUE!) if srcCellRow or srcCellCol do not properly index into
  *  an AreaEval.  If the actual value retrieved Is an ErrorEval, a corresponding 
  *  EvaluationException Is thrown.
  */
 public static ValueEval GetSingleValue(Eval arg, int srcCellRow, short srcCellCol)
 {
     Eval result;
     if (arg is RefEval)
     {
         result = ((RefEval)arg).InnerValueEval;
     }
     else if (arg is AreaEval)
     {
         result = ChooseSingleElementFromArea((AreaEval)arg, srcCellRow, srcCellCol);
     }
     else
     {
         result = arg;
     }
     if (result is ErrorEval)
     {
         throw new EvaluationException((ErrorEval)result);
     }
     if (result is ValueEval)
     {
         return (ValueEval)result;
     }
     throw new Exception("Unexpected eval type (" + result.GetType().Name + ")");
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:37,代码来源:OperandResolver.cs

示例6: Evaluate

        public ValueEval Evaluate(Eval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow,
                int srcCellCol)
        {

            double result;
            try
            {
                int basis = 0; // default
                switch (args.Length)
                {
                    case 3:
                        basis = EvaluateIntArg(args[2], srcCellRow, srcCellCol);
                        break;
                    case 2:
                        basis = EvaluateIntArg(args[2], srcCellRow, srcCellCol);
                        break;
                    default:
                        return ErrorEval.VALUE_INVALID;
                }
                double startDateVal = EvaluateDateArg(args[0], srcCellRow, srcCellCol);
                double endDateVal = EvaluateDateArg(args[1], srcCellRow, srcCellCol);
                result = YearFracCalculator.Calculate(startDateVal, endDateVal, basis);
            }
            catch (EvaluationException e)
            {
                return e.GetErrorEval();
            }

            return new NumberEval(result);
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:30,代码来源:YearFrac.cs

示例7: EvaluateFunc

        /**
         * Replaces part of a text string based on the number of Chars 
         * you specify, with another text string.
         * 
         * @see org.apache.poi.hssf.record.formula.eval.Eval
         */
        public override ValueEval EvaluateFunc(Eval[] args, int srcCellRow, short srcCellCol)
        {
            if (args.Length != 4)
            {
                return ErrorEval.VALUE_INVALID;
            }

            String oldStr = EvaluateStringArg(args[0], srcCellRow, srcCellCol);
            int startNum = EvaluateIntArg(args[1], srcCellRow, srcCellCol);
            int numChars = EvaluateIntArg(args[2], srcCellRow, srcCellCol);
            String newStr = EvaluateStringArg(args[3], srcCellRow, srcCellCol);

            if (startNum < 1 || numChars < 0)
            {
                return ErrorEval.VALUE_INVALID;
            }
            StringBuilder strBuff = new StringBuilder(oldStr);
            // remove any characters that should be replaced
            if (startNum <= oldStr.Length && numChars != 0)
            {
                strBuff.Remove(startNum - 1, startNum - 1 + numChars);
            }
            // now insert (or append) newStr
            if (startNum > strBuff.Length)
            {
                strBuff.Append(newStr);
            }
            else
            {
                strBuff.Insert(startNum - 1, newStr);
            }
            return new StringEval(strBuff.ToString());
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:39,代码来源:Replace.cs

示例8: Evaluate

        public Eval Evaluate(Eval[] args, int srcCellRow, short srcCellCol)
        {
            switch (args.Length)
            {
                case 1:
                    // expected
                    break;
                case 0:
                    // too few arguments
                    return ErrorEval.VALUE_INVALID;
                default:
                    // too many arguments
                    return ErrorEval.VALUE_INVALID;
            }
            Eval firstArg = args[0];

            int result;
            if (firstArg is AreaEval)
            {
                AreaEval ae = (AreaEval)firstArg;
                result = ae.LastRow - ae.FirstRow + 1;
            }
            else if (firstArg is RefEval)
            {
                result = 1;
            }
            else
            { // anything else Is not valid argument
                return ErrorEval.VALUE_INVALID;
            }
            return new NumberEval(result);
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:32,代码来源:Rows.cs

示例9: Evaluate

        public override Eval Evaluate(Eval[] args, int srcRow, short srcCol)
        {
            if (args.Length != 2)
            {
                return ErrorEval.VALUE_INVALID;
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < 2; i++)
            {

                ValueEval ve = SingleOperandEvaluate(args[i], srcRow, srcCol);
                if (ve is StringValueEval)
                {
                    StringValueEval sve = (StringValueEval)ve;
                    sb.Append(sve.StringValue);
                }
                else if (ve is BlankEval)
                {
                    // do nothing
                }
                else
                { // must be an error eval
                    return ve;
                }
            }

            return new StringEval(sb.ToString());
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:28,代码来源:ConcatEval.cs

示例10: Evaluate

        public Eval Evaluate(Eval[] args, int srcCellRow, short srcCellCol)
        {
            int nArgs = args.Length;
            if (nArgs < 1)
            {
                // too few arguments
                return ErrorEval.VALUE_INVALID;
            }

            if (nArgs > 30)
            {
                // too many arguments
                return ErrorEval.VALUE_INVALID;
            }

            int temp = 0;
            // Note - observed behavior of Excel:
            // Error values like #VALUE!, #REF!, #DIV/0!, #NAME? etc don't cause this COUNTA to return an error
            // in fact, they seem to Get Counted

            for (int i = 0; i < nArgs; i++)
            {
                temp += CountUtils.CountArg(args[i], predicate);

            }
            return new NumberEval(temp);
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:27,代码来源:Counta.cs

示例11: Evaluate

 public Eval Evaluate(Eval[] args, int srcCellRow, short srcCellCol)
 {
     Eval arg3 = null;
     switch (args.Length)
     {
         case 4:
             arg3 = args[3]; // important: assumed array element Is never null
             break;
         case 3:
             break;
         default:
             // wrong number of arguments
             return ErrorEval.VALUE_INVALID;
     }
     try
     {
         // Evaluation order:
         // arg0 lookup_value, arg1 table_array, arg3 range_lookup, Find lookup value, arg2 row_index, fetch result
         ValueEval lookupValue = OperandResolver.GetSingleValue(args[0], srcCellRow, srcCellCol);
         AreaEval tableArray = LookupUtils.ResolveTableArrayArg(args[1]);
         bool IsRangeLookup = LookupUtils.ResolveRangeLookupArg(arg3, srcCellRow, srcCellCol);
         int colIndex = LookupUtils.LookupIndexOfValue(lookupValue, LookupUtils.CreateRowVector(tableArray, 0), IsRangeLookup);
         int rowIndex = LookupUtils.ResolveRowOrColIndexArg(args[2], srcCellRow, srcCellCol);
         ValueVector resultCol = CreateResultColumnVector(tableArray, rowIndex);
         return resultCol.GetItem(colIndex);
     }
     catch (EvaluationException e)
     {
         return e.GetErrorEval();
     }
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:31,代码来源:Hlookup.cs

示例12: Evaluate

 public Eval Evaluate(Eval[] args, int srcCellRow, short srcCellCol)
 {
     if (args.Length != 1)
     {
         return ErrorEval.VALUE_INVALID;
     }
     double d;
     try
     {
         ValueEval ve = OperandResolver.GetSingleValue(args[0], srcCellRow, srcCellCol);
         if (ve is BlankEval)
         {
             return NumberEval.ZERO;
         }
         if (ve is StringEval)
         {
             // Note - asymmetric with UnaryMinus
             // -"hello" Evaluates to #VALUE!
             // but +"hello" Evaluates to "hello"
             return ve;
         }
         d = OperandResolver.CoerceValueToDouble(ve);
     }
     catch (EvaluationException e)
     {
         return e.GetErrorEval();
     }
     return new NumberEval(+d);
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:29,代码来源:UnaryPlusEval.cs

示例13: EvaluateFunc

        /**
         *Substitutes text in a text string with new text, some number of times.
         * 
         * @see org.apache.poi.hssf.record.formula.eval.Eval
         */
        public override ValueEval EvaluateFunc(Eval[] args, int srcCellRow, short srcCellCol)
        {
            if (args.Length < 3 || args.Length > 4)
            {
                return ErrorEval.VALUE_INVALID;
            }

            String oldStr = EvaluateStringArg(args[0], srcCellRow, srcCellCol);
            String searchStr = EvaluateStringArg(args[1], srcCellRow, srcCellCol);
            String newStr = EvaluateStringArg(args[2], srcCellRow, srcCellCol);
            

            String result;

            switch (args.Length)
            {
                case 4:
                    int instanceNumber = EvaluateIntArg(args[3], srcCellRow, srcCellCol);
                    if (instanceNumber < 1)
                    {
                        return ErrorEval.VALUE_INVALID;
                    }
                    result = ReplaceOneOccurrence(oldStr, searchStr, newStr, instanceNumber);
                    break;
                case 3:
                    result = ReplaceAllOccurrences(oldStr, searchStr, newStr);
                    break;
                default:
                    throw new InvalidOperationException("Cannot happen");

            }

            return new StringEval(result);
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:39,代码来源:Substitute.cs

示例14: Evaluate

 public Eval Evaluate(Eval[] args, int srcCellRow, short srcCellCol)
 {
     BoolEval beval;
     Eval evalWhenFalse = BoolEval.FALSE;
     switch (args.Length)
     {
         case 3:
             evalWhenFalse = args[2];
             beval = (BoolEval)args[0]; // TODO - class cast exception
             if (beval.BooleanValue)
             {
                 return args[1];
             }
             return evalWhenFalse;
         case 2:
             beval = (BoolEval)args[0]; // TODO - class cast exception
             if (beval.BooleanValue)
             {
                 return args[1];
             }
             return evalWhenFalse;
         default:
             return ErrorEval.VALUE_INVALID;
     }
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:25,代码来源:If.cs

示例15: Evaluate

        public Eval Evaluate(Eval[] evals, int srcCellRow, short srcCellCol)
        {
            if (evals.Length > 0)
            {
                return ErrorEval.VALUE_INVALID;
            }

            return new NumberEval(HSSFDateUtil.GetExcelDate(DateTime.Today));
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:9,代码来源:Today.cs


注:本文中的Eval类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。