从JINT(服务器端)运行C#代码

从JINT(服务器端)运行C#代码,c#,jint,C#,Jint,这可能不是JINT的正确用法,如果有人知道其他系统可以做到这一点,我对他们持开放态度,只要他们可以序列化为字符串-但本质上我需要找到一种使用JINT解析和运行C代码的方法。作为一个整体,我对JINT的概念非常陌生,所以我不确定到底要寻找什么。但我希望能够设置一些类似于 public int GetValue(string name){ // database work to find the value requested // return the value found }

这可能不是JINT的正确用法,如果有人知道其他系统可以做到这一点,我对他们持开放态度,只要他们可以序列化为字符串-但本质上我需要找到一种使用JINT解析和运行C代码的方法。作为一个整体,我对JINT的概念非常陌生,所以我不确定到底要寻找什么。但我希望能够设置一些类似于

public int GetValue(string name){
    // database work to find the value requested
    // return the value found
}

string s = "GetValue('something') * 2";
并且能够解析字符串并运行它,执行GetValue并传入给定参数。在JINT或其他类似的框架中是否可以实现类似的功能?

您可以从jintengine轻松设置函数(字符串名称、委托函数)

JintEngine引擎=新JintEngine();
Func function=GetValue;
engine.SetFunction(“GetValue”,函数);
var run=engine.run(“GetValue('something')*2”);
您可以从jintengine轻松设置函数(字符串名称、委托函数)

JintEngine引擎=新JintEngine();
Func function=GetValue;
engine.SetFunction(“GetValue”,函数);
var run=engine.run(“GetValue('something')*2”);
这正是我想要做的!非常感谢你!这太完美了。这正是我想要做的!非常感谢你!这太完美了。
JintEngine engine=new JintEngine();
Func<string,int> function = GetValue;
engine.SetFunction("GetValue", function);
var run = engine.Run("GetValue('something') * 2");