Created
January 1, 2013 21:50
-
-
Save atheken/4430284 to your computer and use it in GitHub Desktop.
Is this how you use mono's evaluator?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static dynamic ParseFunc (string func, out string error) | |
{ | |
dynamic retval = null; | |
error = null; | |
using (var ms = new MemoryStream()) { | |
using(var tr = new StreamWriter(ms)){ | |
var settings = new CompilerSettings(); | |
var reporter = new StreamReportPrinter(tr); | |
var cc = new CompilerContext(settings, reporter); | |
var eval = new Evaluator (cc); | |
var result = eval.Evaluate(func); | |
} | |
ms.Position = 0; | |
using(var sr = new StreamReader(ms)){ | |
error = sr.ReadToEnd(); | |
} | |
} | |
return retval; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment