Do you mean you'd call it like "AddNumbers().Do(3, 4)"? This is really easy. Make AddNumbers public, then do:
import clr clr.AddReference('MyAssembly') import AddNumbers AddNumbers().Do(3, 4) If you really want to do AddNumbers(3, 4) then you'd just write it as: public class AddNumbers { public AddNumbers(params object[] args) { Do(args); } public string Do( params object[] args ) { ..check args.. ..add the two arguments.. ..return the result as a string.. } } And do the same: import clr clr.AddReference('MyAssembly') import AddNumbers AddNumbers(3, 4) > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:users- > [EMAIL PROTECTED] On Behalf Of Jeff Slutter > Sent: Thursday, December 04, 2008 1:14 PM > To: Discussion of IronPython > Subject: [IronPython] Calling functions in IronPython that don't really > exist > > I'm writing an application that I want to provide runtime scripting via > IronPython for. This application loads "plug-ins" from assemblies to > add > functionality. > > Each plug-in is a class with, for the sake of simplicity, a "Do" > function. > > What I'm trying to figure out is that if I have a class like: > > class AddNumbers > { > public string Do( params object[] args ) > { > ..check args.. > ..add the two arguments.. > ..return the result as a string.. > } > } > > > That I could call it from IronPython like: > > AddNumbers( 3, 4 ) > > When that happens a new instance of the AddNumbers class is created, > the > arguments are then passed to the Do member function, the result is > returned back to Python. > > This may seem like a weird way for scripting. But, doing it this way I > can do some other important things, such as keeping a history of the > commands. If, along with Do, the commands have Undo and Redo functions, > then I can keep the instances of the commands stored and should the > user > need to undo their command, I can internally run the Undo function. > > Any ideas on how I should approach this? I don't mind having to do a > good chunk of backend work so that to add new command plugins, I just > have to write a class with a Do function and possibly provide some > Attributes if necessary. If I have to make some concessions that is > fine, but I need to stick with the concept of creating an instance of a > class and executing a function to perform the operation. > > I assume I'm either going to have to generate some sort of thunk > function (I have no idea where to start) or provide some sort of > 'command runner' that really gets called. > > Any help or guidance is mighty appreciated, > Jeff > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com