0

This is probably not the correct use of JINT, and if anyone knows of other systems that can do this, I am open to them, as long as they can serialize to a string - but essentially I need to find a way to use JINT to parse and run C# code. I am very new to the idea of JINT as a whole, so I am not sure exactly what to go around searching for. But I'd like to be able to setup something like ...

public int GetValue(string name){ // database work to find the value requested // return the value found } string s = "GetValue('something') * 2"; 

And be capable of parsing the string and running it, with GetValue executing and passing in the given parameter. Is something like this possible in JINT, or another similar framework?

1 Answer 1

3

You can easily SetFunction(string name, Delegate function) from jintengine

documentation

JintEngine engine=new JintEngine(); Func<string,int> function = GetValue; engine.SetFunction("GetValue", function); var run = engine.Run("GetValue('something') * 2"); 
Sign up to request clarification or add additional context in comments.

1 Comment

That is exactly what I was trying to do! Thank you so much! This is perfect.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.