文件名称:c# eval 函数
文件大小:10KB
文件格式:ZIP
更新时间:2013-05-15 09:32:21
eval 动态运行变量中的内容 求值的解析表达式
Console.WriteLine("Test0: {0}", Evaluator.EvaluateToInteger("(30 + 4) * 2")); Console.WriteLine("Test1: {0}", Evaluator.EvaluateToString("\"Hello \" + \"There\"")); Console.WriteLine("Test2: {0}", Evaluator.EvaluateToBool("30 == 40")); Console.WriteLine("Test3: {0}", Evaluator.EvaluateToObject("new DataSet()")); EvaluatorItem[] items = { new EvaluatorItem(typeof(int), "(30 + 4) * 2", "GetNumber"), new EvaluatorItem(typeof(string), "\"Hello \" + \"There\"", "GetString"), new EvaluatorItem(typeof(bool), "30 == 40", "GetBool"), new EvaluatorItem(typeof(object), "new DataSet()", "GetDataSet") }; Evaluator eval = new Evaluator(items); Console.WriteLine("TestStatic0: {0}", eval.EvaluateInt("GetNumber")); Console.WriteLine("TestStatic1: {0}", eval.EvaluateString("GetString")); Console.WriteLine("TestStatic2: {0}", eval.EvaluateBool("GetBool")); Console.WriteLine("TestStatic3: {0}", eval.Evaluate("GetDataSet"));
【文件预览】:
Evaluator
----Evaluator.sln(1KB)
----Evaluator.suo(8KB)
----Evaluator.csproj.user(2KB)
----Evaluator.cs(4KB)
----TestEvaluator()
--------TestEvaluator.csproj(4KB)
--------TestEvaluator.csproj.user(2KB)
--------App.ico(1KB)
--------AssemblyInfo.cs(2KB)
--------Test.cs(1KB)
----Evaluator.csproj(4KB)
----AssemblyInfo.cs(2KB)