[IronPython] importing C# functions

Slide slide.o.mix at gmail.com
Sat Aug 5 20:49:52 CEST 2006


So I just need to make sure my functions are static? The main goal of
this was to allow runtime addition of functions for a module. I was
hoping to do something like

EngineModule mod = _engine.CreateModule("mymodule", true);

mod.AddMethod(someObject, "mymethod", someDelegate);

Then I would be able to call mymodule.mymethod inside of python
scripts, but I guess that might be a pipe dream.

thanks

slide


On 8/5/06, Stefan Rusek <s at rusek.org> wrote:
> Tell him to look into using IronPython instead of normal python. IP is
> written completely in C# and has really good .net support, and he should be
> able to declare a static method and use it like normal function in python.
>
> --Stefan
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com
> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Saturday, August 05, 2006 7:37 AM
> To: users at lists.ironpython.com
> Subject: Re: [IronPython] importing C# functions
>
>
> Slide wrote:
> > I am currently adding a scripting console to one of the applications I
> > develop. I would like to, at runtime, add functions that can be called
> > by the python code in the console. Something like
> >
> > // c#
> > public int AddIt(int a, int b)
> > {
> >     return a + b;
> > }
> >
>
> Does C# allow you to define functions outside of objects ? I didn't
> think so...
>
> You can create static methods on objects though.
>
> > then, I would like to add that function (and possibly functions from
> > plugins) so they can be called from python. Do I need to create a
> > module and add the functions to the module? Is there a better way?
> >
>
> For an example of creating a dll from C#, and then accessing from
> IronPython, see :
>
> http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_29.shtml#e406
>
> All the best,
>
> Fuzzyman
> http://www.voidspace.org.uk/python/index.shtml
>
> > Thanks,
> >
> > slide
> > _______________________________________________
> > 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
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>



More information about the Ironpython-users mailing list