Created
March 3, 2015 23:26
-
-
Save felixlindemann/1af5ba8619b56594ab83 to your computer and use it in GitHub Desktop.
Evalute Line and Fire Event including the Feedback of R
This file contains 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
private SymbolicExpression EvaluateLine(String cmd) | |
{ | |
String result = ""; | |
// getTempfile name for sink | |
FileInfo f = new FileInfo(Path.GetTempFileName()); | |
SymbolicExpression s = null; | |
try | |
{ | |
// Activate sink | |
this.rEngine.Evaluate(string.Format("sink(\"{0}\")", f.FullName.Replace("\\", "/"))); | |
// Evaluate Command and add Result to result list. | |
s = rEngine.Evaluate(cmd); | |
} | |
catch (Exception ex) | |
{ | |
throw ex; | |
} | |
finally | |
{ | |
// End sink | |
this.rEngine.Evaluate("sink()"); | |
// read sink-Output from tempfile | |
result = File.ReadAllText(f.FullName); | |
// delete tempfile | |
this.rEngine.Evaluate(string.Format("unlink(\"{0}\")", f.FullName.Replace("\\", "/"))); | |
// fire Event | |
CommandExecuted(new RExececutedEventArgs(cmd, result, s)); | |
} | |
return s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment