views:

85

answers:

1

Assume the following code:

public class Foo
{
    public string Bar { get; set; }
}

How can I instantiate an instance of Foo in the following code?

ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null);
ScriptRuntime runtime = new ScriptRuntime(setup);
ScriptEngine engine = Python.GetEngine(runtime);
ScriptScope scope = engine.CreateScope();

string script = @"x = ***???***";
ScriptSource source = engine.CreateScriptSourceFromString(script, SourceCodeKind.Statements);
source.Execute(scope);
+1  A: 
string script = @"
  import clr
  clr.AddReference('FooNamespace')
  from FooNamespace import *
  x = Foo()";
sipwiz