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

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

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

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

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

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

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

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