Are you trying to get rid of the "foo.Bar" or do you want the user to be typing something like "MyObjectModel.Bar"? Or are you just wanting the user to type "Bar"? You can just pass the instance of the class in and the user can dot through it and call methods on it - as far as they're concerned there's not much of a difference between static vs. instance - it's either dotting through the class name or the instance name.
If you really want the user to just type "Bar" the good news is that you'll be able to do it in a future version. You'll just need to subclass DynamicObject and put a dictionary in it for storing additional attributes. Then you can add your methods to it and pass it as the storage for a scope. You can also override TryGetMember and then do the lazy lookup of attributes as well. Unfortunately it doesn't work right now in 2.6 due to a bug in IronPython (you get an exception saying __doc__ is readonly). It is fixed in the 2.7 branch though and I can look at backporting it to 2.6.x. This is the way we really want things to work going forward though - scopes are just dynamic objects. That will enable you to have thinks like static properties or fields which languages can bind to very tightly and get really high performance global variable lookups. > -----Original Message----- > From: users-boun...@lists.ironpython.com [mailto:users- > boun...@lists.ironpython.com] On Behalf Of Ross Hammermeister > Sent: Wednesday, June 23, 2010 9:27 AM > To: Discussion of IronPython > Subject: Re: [IronPython] Modules in hosted enviroment > > This is almost what I want but I to pass and instance of a class(no static > methods) and have python treat it as if it were static method. After > re-evaluating what I want I can see why it might not be possible. So if it > ends up that I can't do what I described I will use on of the many other > methods indicated. > > Thanks for the help > > -------------------------------------------------- > From: "Dino Viehland" <di...@microsoft.com> > Sent: Tuesday, June 22, 2010 6:56 PM > To: "Discussion of IronPython" <users@lists.ironpython.com> > Subject: Re: [IronPython] Modules in hosted enviroment > > > Jeff wrote: > >> Hi Ross, > >> It sounds like you want Dino's suggestion IAttributesCollection, which > >> will give you much more flexibility. I've never done that, but it > >> looks fairly straightforward. > >> > >> > An unrelated issue I have with ScriptScope is I can't figure out to add > >> > overloaded functions with different parameter counts for defaults I'm > >> > using > >> > 3.5 if it matters. > >> > >> Dino? > > > > I assume what you have here is a bunch of static methods declared > > somewhere and > > you want to publish them in the scope? The only way to really go about > > doing > > this is getting the BuiltinFunction object for them and then publishing > > that > > in the scope. To get the BF you'll need to first get the PythonType and > > then > > get the BF. Such as: > > > > public class MyObjectModel { > > public static void Foo() { > > } > > > > public static void Foo(object x) { > > } > > } > > > > Using C# 4.0 then I think you could do: > > > > dynamic foos = > > ((dynamic)DynamicHelpers.GetPythonTypeFromType(typeof(MyObjectModel))).Foo; > > > > or you could do: > > > > object foos = > > > engine.Operations.GetMember(DynamicHelpers.GetPythonTypeFromType(typeof(MyObje > ctModel))), > > "Foo"); > > _______________________________________________ > > 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 _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com