Joshua J. Pearce wrote:
> 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.
You should be able to place objects into the 'user scope' using the
same SetVariable technique. That way the user can call methods on these
objects from their code.
ScriptDomainManager.CurrentManager.Host.DefaultModule.SetVariable("SomeName",
SomeObject);
SomeObject is then available to user code as SomeName...
Michael
http://www.manning.com/foord
>
> Many thanks!
>
> - Josh Pearce
>
> On 10/18/07, *JoeSox* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>
> On 10/17/07, Joshua J. Pearce <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> 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
> [email protected] <mailto:[email protected]>
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
>
> --
> Joshua Pearce
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com