[IronPython] Accesses static ResourceManager from IronPython
dinov at exchange.microsoft.com
Tue Dec 19 00:43:19 CET 2006
Sorry, that 1st line should have been Ops.GetDynamicTypeFromType(typeof(PublicResources)).
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Monday, December 18, 2006 3:42 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Accesses static ResourceManager from IronPython
If you want to follow the way you're currently doing it you can just publish the DynamicType in Globals, eg:
Globals['foo'] = Ops.GetDynamicType(typeof(PublicResources));
You can also add a reference to your C# DLL and then the user can import all of your public types / namespaces (although that may not be what you want). E.g.:
then users can either do import Namespace or import SomeType (assuming the type has no namespace) or from Namespace import SomeType. This would be the equivalent to if the user did:
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Chris Stoy
Sent: Monday, December 18, 2006 3:29 PM
To: users at lists.ironpython.com
Subject: [IronPython] Accesses static ResourceManager from IronPython
I'm working on embedding IronPython into a larger C# application to allow end-users the ability to write scripts. One thing I want to do is provide a set of icon resources in the C# code and expose them to IronPython so a user can access them. I created a new Resource.resx file called "PublicResources" in my C# application. This creates a class called "PublicResources" that contains a set of static methods to access the resources in a type-safe way. Although I can expose the underlying ResourceManager instance to IP, what I really want is the class PublicResources exposed so I can us it in my IronPython code.
For example, in C# I would say:
Form myForm = new Form();
myForm.Icon = PublicResources.MyFormIcon;
and in IronPython, I want to say:
myForm = Form()
myForm.Icon = PublicResources.MyFormIcon
So, I guess this boils down to "how do I expose static classes from C# to IronPython?"
(On a side note, if anyone knows where there is some documentation on the proper way to expose .NET class to IronPython I would appreciate it. Currently I'm creating a new module with PythonEngine.CreateModule(), adding objects to the Globals, and importing it using PythonEngine.Import()...but I have no idea if that is the right way to do it.)
Thanks a lot for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users