Sorry... the type of "theClass" should actually be PythonType and not
object.
On Fri, Feb 22, 2008 at 8:18 AM, Curt Hagenlocher <[EMAIL PROTECTED]>
wrote:
> Here's a snippet that I'm using under A8. I can't promise that everything
> is "right", but it works correctly for how I'm using it.
>
> // Load Class1.py into a new scope
> SourceUnit source =
> PythonEngine.CurrentEngine.CreateScriptSourceFromFile("Class1.py");
> IScriptScope m = PythonEngine.CurrentEngine.CreateScope();
> PythonEngine.CurrentEngine.Execute(m, source);
>
> // Get the class object for "Class1"
> object value;
> m.TryGetVariable("Class1", out value);
> object theClass = (value as PythonType);
> // Instantiate "Class1"
> LanguageContext language = LanguageContext.FromEngine(
> PythonEngine.CurrentEngine);
> Scope scope = new Scope(language);
> CodeContext context = new CodeContext(scope, language);
> object theValue = new PythonTypeOps.TypeCaller(theClass).Call(context2,
> new object[0]);
>
> // Call the "Clone function on the new instance
> object theFunction =
> PythonEngine.CurrentEngine.Operations.GetMember(theValue,
> "Clone");
> object result = PythonEngine.CurrentEngine.Operations.Call(theFunction,
> new object[] { s, i });
> result = PythonEngine.CurrentEngine.Operations.ConvertTo<int>(result);
>
> On Fri, Feb 22, 2008 at 6:51 AM, Fernando Correia <
> [EMAIL PROTECTED]> wrote:
>
> > I am trying out IronPython hosting on C#. I found out an article about
> > hosting with 2.0 Alpha 6:
> >
> >
> > http://blogs.msdn.com/rdawson/archive/2007/11/29/hosting-ironpython-2-0-alpha-6-via-the-dlr.aspx
> >
> > But those instructions don't seem to work with 2.0 Alpha 8. I've
> > searched the Web but I couldn't find updated instructions.
> >
> > If someone can give me a pointer, I'd appreciate.
> >
> > _______________________________________________
> > Users mailing list
> > [email protected]
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
>
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com