I was poking around within the DLR code that was release yesterday within the IronPython Alpha release and I came across the Script class which allow local hosting of a script. Given a language provider you can then execute a block of code. Internally the ScriptEnvironmentSetup loads 4 LanguageProviderSetup classes currently
- IronPython.Hosting.PythonLanguageProvider
- Microsoft.JScript.Compiler.Hosting.LanguageProvider
- Microsoft.VisualBasic.Scripting.Hosting.VisualBasicLanguageProvider
- Ruby.Hosting.RubyLanguageProvider
Unfortunately it appears they are only including the IronPython.Hosting.PythonLanguageProvider with this current release. A quick example of what you can do, the Script class is a wrapper around the ScriptDomainManager:
using System;
using Microsoft.Scripting;
namespace IronPythonScriptHost
{
class Program
{
static void Main(string[] args)
{
string code = "print \"Hello\" + Name";
Script.SetVariable("Name", "Nick");
Script.Execute("py", code);
Console.Read();
}
}
}