示例#1
0
        /// <summary>
        /// 执行表达式并返回布尔型值
        /// </summary>
        /// <param name="code">要执行的表达式</param>
        /// <returns>运算结果</returns>
        static public bool EvaluateToBool(string code)
        {
            EvalHelper eval = new EvalHelper(typeof(bool), code, staticMethodName); //生成 Evaluator 类的对像

            return((bool)eval.Evaluate(staticMethodName));                          //执行并返回布尔型数据
        }
示例#2
0
        /// <summary>
        /// 执行表达式并返回 object 型值
        /// </summary>
        /// <param name="code">要执行的表达式</param>
        /// <returns>运算结果</returns>
        static public object EvaluateToObject(string code)
        {
            EvalHelper eval = new EvalHelper(typeof(object), code, staticMethodName); //生成 Evaluator 类的对像

            return(eval.Evaluate(staticMethodName));                                  //执行并返回 object 型数据
        }
示例#3
0
        /// <summary>
        /// 执行表达式并返回字符串型值
        /// </summary>
        /// <param name="code">要执行的表达式</param>
        /// <returns>运算结果</returns>
        static public string EvaluateToString(string code)
        {
            EvalHelper eval = new EvalHelper(typeof(string), code, staticMethodName); //生成 Evaluator 类的对像

            return((string)eval.Evaluate(staticMethodName));                          //执行并返回字符串型数据
        }
示例#4
0
        /// <summary>
        /// 执行表达式并返回十进制数值
        /// </summary>
        /// <param name="name">执行字符串名称</param>
        /// <returns>执行结果</returns>
        static public decimal EvaluateToDecimal(string code)
        {
            EvalHelper eval = new EvalHelper(typeof(decimal), code, staticMethodName);//生成 Evaluator 类的对像

            return((decimal)eval.Evaluate(staticMethodName));
        }
示例#5
0
        /// <summary>
        /// 执行表达式并返回长整型数值
        /// </summary>
        /// <param name="name">执行字符串名称</param>
        /// <returns>执行结果</returns>
        static public long EvaluateToLong(string code)
        {
            EvalHelper eval = new EvalHelper(typeof(long), code, staticMethodName);//生成 Evaluator 类的对像

            return((long)eval.Evaluate(staticMethodName));
        }
示例#6
0
        /// <summary>
        /// 执行表达式并返回双精度值
        /// </summary>
        /// <param name="name">执行字符串名称</param>
        /// <returns>执行结果</returns>
        static public double EvaluateToDouble(string code)
        {
            EvalHelper eval = new EvalHelper(typeof(double), code, staticMethodName);//生成 Evaluator 类的对像

            return((double)eval.Evaluate(staticMethodName));
        }
示例#7
0
        /// <summary>
        /// 执行表达式并返回整型值
        /// </summary>
        /// <param name="code">要执行的表达式</param>
        /// <returns>运算结果</returns>
        static public int EvaluateToInteger(string code)
        {
            EvalHelper eval = new EvalHelper(typeof(int), code, staticMethodName); //生成 Evaluator 类的对像

            return((int)eval.Evaluate(staticMethodName));                          //执行并返回整型数据
        }