[IronPython] Need a Good Embedded Example
Joshua J. Pearce
joshua.pearce at gmail.com
Thu Oct 18 16:48:02 CEST 2007
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.
- 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
> > 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
> > IP engine, but that's way too much overhead.
> > //How can I say: "Hey, pe, here is a method on my object, myAppService,
> > 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...
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users