原理﹕
使用js.net(由于里面有eval方法)编写一个类﹐类别中新增一个方法来执行动态js代码。
而后使用jsc.exe把它编译成一个dll
在c#项目中把它加入﹐而后传入动态代码﹐呼叫这个类别的这个方法﹐获得结果。
1.第一步﹐新增一个js文件
MyEval.jsc#

class MyEval{

function execute(code:String) :String { // Method.

return eval(code);

}

}
2.编译成dll测试

jsc /target:library /out:MyEval.dll MyEval.js
3.编写测试文件
TestEval.csspa

using System;
class test
{
public static void Main(){
string code = "var result:int =0;result==1?\"成功\":\"失败\"";
MyEval eval = new MyEval();
string result = eval.execute(code);
Console.WriteLine("The Result is:" + result);
}
}