Nick Parker
My ramblings on .NET...

DLR Hosting Services

Tuesday, 1 May 2007 21:31 by nickp

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(); 
}
}
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Open Source | .NET | Software | DLR
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

August 27. 2008 21:21