[IronPython] Need a Good Embedded Example
Joshua J. Pearce
joshua.pearce at gmail.com
Thu Oct 18 16:48:02 CEST 2007
Joesox,
Thank you very much! Now, what if I the getcount() method was actually
getcount(string arg1), is there a way to call it from within the IP script?
Or do I need to parse the IP script ahead of time, and call the function
myself? That would be like writing my own scripting language, so I hope
there is a way to call the method from within IP scripts.
Many thanks!
- Josh Pearce
On 10/18/07, JoeSox <joesox at gmail.com> wrote:
>
> On 10/17/07, Joshua J. Pearce <joshua.pearce at gmail.com> wrote:
> > OK, please forgive my earlier vagueness. What I want to do is as
> follows:
> >
> > pe = PythonEngine.CurrentEngine;
> >
> > //create a instance of my applications business logic layer class
> > myAppService = new AppService(_token);
> >
> > //I want to be able to somehow make methods from the myAppService class
> > available to be called from Iron Python code.
> >
> > //I know I could import the AppService dll and create my own instance in
> the
> > IP engine, but that's way too much overhead.
> >
> > //How can I say: "Hey, pe, here is a method on my object, myAppService,
> that
> > I want you to make available when you execute a command?
>
>
> What are the return values of myAppService.ServiceMethod()?
> Depending upon these values, you will need to handle them before
> sending them to the pe.
>
> So it sounds like you need something like:
>
> public int COUNT;
>
> private void MyIPGetCount()
> {
> //Call your Service method and assign return value to a global
> COUNT = myAppService.getcount();
>
> //Create variable bridge from C# to IronPython engine
> //I like to pretend I am just using a IP command line to help
> figure out what I need to do
> pe.ExecuteCommand("PyCount = 0");
>
> //Set the IronPython bridge variables...
> ScriptDomainManager.CurrentManager.Host.DefaultModule.SetVariable
> ("PyCount",
> COUNT);
> pe.ExecuteCommand("PyCountTwo = PyCount");
> }
>
> This is a simplified version of what I am guess what you need to do
> but there you go.
> --
> Later, JoeSox
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
--
Joshua Pearce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20071018/f0842828/attachment.html>
More information about the Ironpython-users
mailing list