Trying to figure out how to exploit the CSharpCodeProvider to compile string data at runtime.
In xml, i have what will amount to a predicate condition stored in a string.
I want to be able to, within the current context, execute and get the result of these statements.
for instance when
<Condition>Value=="ABCD1234"</Condition> is read and executed, it should look in the current object scope for value and return true or false based on the evaluation of the statement.
I think i’m going the right direction with CSharpCodeProvider, however all the examples i can find relate to compiling to a .DLL or .EXE, i really just want to compile in memory so i can perform the comparison and return true or false to another part of the app.
Any ideas as to how best to approach this? is CSharpCodeProvider even the best tool for the job?
I would highly recommend using FLEE for something like this. It doesn’t know native C# but it has the ability to parse and execute a reasonable subset of functions that looks like it’d be suitable for your use.
I’ve used FLEE on many occasions and found it to be easy to use and plenty fast enough.