Skip to content

Instantly share code, notes, and snippets.

@atheken
Created January 1, 2013 21:50
Show Gist options
  • Save atheken/4430284 to your computer and use it in GitHub Desktop.
Save atheken/4430284 to your computer and use it in GitHub Desktop.
Is this how you use mono's evaluator?
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