[IronPython] Accessing classes defined in hosting c# application

Hannes Rahm inflyttningshest at gmail.com
Thu Sep 11 07:59:05 CEST 2008


Thanks for the quick answers! I rewrote my app to use ScriptRuntime instead
of the old (i guess) PythonEngine method.

Once I knew about ScriptRuntime I found this quickly:
http://blogs.msdn.com/seshadripv/archive/2008/07/23/how-to-create-objects-of-types-defined-in-c-inside-a-hosted-python-script.aspx

/Hannes

2008/9/10 Curt Hagenlocher <curt at hagenlocher.org>

> Are you exposing your hosting assembly to Python by calling
> ScriptRuntime.LoadAssembly? If so, you ought to be able to import your
> Entity class directly into Python and derive from it.
>
> On Wed, Sep 10, 2008 at 4:32 AM, Hannes Rahm <inflyttningshest at gmail.com>wrote:
>
>> Hello people!
>>
>> I am developing a small multiplayer game in c# (using xna for graphics).
>> On the server side I am doing a lot of the logic programming in
>> IronPython.
>>
>> I have gotten to the point where I want to inherit from my "Entity" class
>> defined in the hosting application source (c#) so I can specialize it for
>> different purposes in IronPython.
>> I do not know how to accomplish this.
>>
>> I have temporarily solved this by having a python wrapper class around the
>> c# object (which I have to create using a CreateEntity() function in one of
>> the global objects I pass in from "outside"). Alternatively I can add a
>> public object ScriptingObject; that I can fill with what I want from python.
>> But both these solutions seem a tad bit inelegant.
>>
>> Does anyone have any ideas on how to do this?
>>
>> Best regards
>> /Hannes
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
>
> _______________________________________________
> 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/20080911/3f111066/attachment.html>


More information about the Ironpython-users mailing list