[IronPython] Embedding IronPython and calling python functions from C#
empirebuilder at gmail.com
Thu Jun 11 18:08:46 CEST 2009
You can read all yours file scripts, then using StringBuilder to combine
then and call CreateScriptSourceFromString()Then you can call your functions
within the combined scripts normally. Pretty much you are creating a giant
source code on the fly.
On Thu, Jun 11, 2009 at 5:32 PM, Patrick van der Willik <
patrick at toolmaker.nl> wrote:
> I'm currently attempting to embed the IronPython 2 runtimes into an
> existing application written in C#. However, I find the amount of
> documentation lacking on what I'm trying to do. I currently have a
> proof-of-concept version which uses Lua and LuaInterface, but the people who
> have to write the scripts dislike Lua(Well, more hate it with a passion) and
> would love to see this working with Python.
> My host application is a networked application that must trigger certain
> scripts functions on events generated by the connected clients. The idea is
> that when my application starts, it will load the IronPython script
> environment, launches an 'autoexec.py' which will load various other scripts
> files and do some housekeeping. Once this all is completed, it will start
> listening to incoming connections. However, in various scenarios, the
> application has to trigger scripted functions when data is received from a
> client. Which script function is called is different per client and per
> event. I have events for connecting, logging on, disconnecting and a set of
> data specific events after receiving data. This highly depends on the
> received packets.
> My question here is: How do I embed IronPython in such a fashion that I can
> load my scripts and then trigger various functions within that? I've seen
> many examples that just call CreateScriptSourceFromString() or File each
> time in which just 1 piece of code is implemented. This is not suitable for
> the needs here because the scripted systems can become quite complex.
> With regards,
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users