[IronPython] Need a Good Embedded Example

Joshua J. Pearce joshua.pearce at gmail.com
Thu Oct 18 02:29:27 CEST 2007


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?

Thanks,

-Josh Pearce




On 10/17/07, JoeSox <joesox at gmail.com> wrote:
>
> On 10/17/07, Joshua J. Pearce <joshua.pearce at gmail.com> wrote:
> > I am looking for an embedded IronPython 2.0 example beyond the simple
> hello
> > world one I quoted before.
> >
> > What I want to know is:
> >
> > 1) How to get variable output from the script back to my c# code.
>
> I have a quick section in this article...
> http://www.codeproject.com/useritems/pswrdgeniron.asp
>
> You can view the source here...
>
> http://pswrdgen.googlecode.com/svn/trunk/pswrdgeniron/pswrdgeniron/Form1.cs
>
>
> Microsoft.Scripting.ScriptDomainManager.CurrentManager.Host.DefaultModule.SetVariable
>
> > 2) How to call scripts with multiple statements.
>
> multiple statements? Do you mean call the methods in an imported script?
>
> > 3) Do all variables need to be set on the script object, or can their
> > declaration just be part of the script code?
>
> It depends what you are doing and how your app is designed.
>
> > 4) Is there a good and simple example anywhere that shows how to host
> the
> > IronPython engine in a c# app and let users manipulate your program
> objects
> > via ipy scripts?
>
> My article above.
>
> > 5) How can I expose c# methods to as IPY functions?
>
> Not sure I understand your question here. Can't you have a c# method
> then do something like pe.Execute("my py code here")?
> --
> 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/20071017/233e98fb/attachment.html>


More information about the Ironpython-users mailing list