[IronPython] Iron Python NewB questions . . .

Dave Purrington dave.purrington at gmail.com
Mon Nov 2 23:22:46 CET 2009


Mike in this case is probably Michael Foord.
http://www.ironpythoninaction.com/

Here's a good place to start (from Mike's blog):
http://www.voidspace.org.uk/ironpython/hosting_api.shtm

There are lots of variations of hosting, and many patterns. Sounds like you
might be wanting to define classes in IPy and instantiate them. Basically,
you run the script that defines the class, then get the class object from
the runtime scope, then invoke the constructor which returns an instance of
the object. Casting should work in that case (provided of course that you've
derived from the type in question). For example:

        public T Load<T>(string path, params object[] parameters) where T :
class {

                ScriptSource script =
_engine.CreateScriptSourceFromFile(path);
                CompiledCode code = script.Compile();
                string className = Path.GetFileNameWithoutExtension(path); #
this is just a convention
                object theClass = _scope.GetVariable(className);
                object instance = _engine.Operations.Invoke(theClass,
parameters);
                return instance as T;
    }

This isn't the only info you need, but should give you an idea of how it
works. Try searching for "ironpython hosting"

Hope this helps.

On Mon, Nov 2, 2009 at 4:59 PM, Frank Merrow <fmerrow at qualcomm.com> wrote:

> At 01:43 PM 11/2/2009, Justin Regele wrote:
>
>> Embedding IPy in C# isn't easy at first, and definitely not super
>> straight-forward, but there are alot of options of how to do it. Get Mike's
>> book, or at least download the source for the embedding chapter. Embedding
>> ironpython is tricky now, but things are progressing quickly, and there ARE
>> lots of ways to do it--different techniques for different situations.
>>
>
> Okay, maybe everyone on this list knows, but I don't . . .
>
> Mike Who and what book?
>
>
> Frank
>
> _______________________________________________
> 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/20091102/bda6d4c8/attachment.html>


More information about the Ironpython-users mailing list