[IronPython] Modules in hosted enviroment
Ross Hammermeister
glitch17 at gmail.com
Wed Jun 23 18:26:30 CEST 2010
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" <dinov at microsoft.com>
Sent: Tuesday, June 22, 2010 6:56 PM
To: "Discussion of IronPython" <users at 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(MyObjectModel))),
> "Foo");
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
More information about the Ironpython-users
mailing list