IronPython: how can I run init code when I import a module using clr.AddReference()? -



IronPython: how can I run init code when I import a module using clr.AddReference()? -

i wondering if there way init code run upon importing .net assembly using clr.addreference(), in same way importing python file executes init.py code resides in same directory. in advance!

it's not possible clr.addreference, far know.

if assembly has ironpython module, can run code when imported (a la __init__.py). ironpython module pretty simple set up:

[assembly: pythonmodule("mymodule", typeof(mymodule))] public static class mymodule { [specialname] public static void performmodulereload(pythoncontext/*!*/ context, pythondictionary/*!*/ dict) { // module initialization code } // variables, functions, classes, etc. appear in module }

don't confused "reload" part of name; it's called when module loaded every time reloaded.

if assembly used outside of ironpython, can set module in separate assembly references original module. if want examples of how write modules, check out source ironpython.modules project on http://ironpython.codeplex.com.

ironpython

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -