Execute<T> With IronRuby
Posted by: K. Scott Allen,
on 04 Oct 2011 |
View original | Bookmarked: 0 time(s)
Imagine (or dream) that you have some IronRuby code to execute. require 'net/telnet'
host = Net::Telnet.new(:Host => 'localhost')
#...
#...
#...
return data
One way to execute the code and capture the result is to use Execute<T> on the ScriptEngine object.
public T Execute<T>(string fileName)
{
var script = File.ReadAllText(fileName);
var engine = IronRuby.Ruby.CreateEngine();
engine.SetSearchPaths(
SearchPaths // will contain paths like:
// @"C:\Program...