/// <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)); //执行并返回布尔型数据 }
/// <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 型数据 }
/// <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)); //执行并返回字符串型数据 }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); //执行并返回整型数据 }