[IronPython] Hosting IronPython 2.0 Alpha 8
Curt Hagenlocher
curt at hagenlocher.org
Fri Feb 22 17:19:31 CET 2008
Sorry... the type of "theClass" should actually be PythonType and not
object.
On Fri, Feb 22, 2008 at 8:18 AM, Curt Hagenlocher <curt at hagenlocher.org>
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 <
> fernandoacorreia at gmail.com> 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
> > Users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080222/1af4d945/attachment.html>
More information about the Ironpython-users
mailing list