Posted by
Joseph on
9/26/2004 11:50 AM |
Comments (2)
The web has a nice way of bringing things around full circle (or my brain notices co-incidences and attaches “meaning” to them). I played around late last week writing some custom attributes. I was interested in doing some method interception, and also maybe subscribing to some events on the decorated class. It seems that writing a custom attribute that actually DOES something by its self (rather than just being a piece of meta-data that can be queried reflectively by some other bit of code) is somewhat hard. If you inherit from
ProxyAttribute and are applied to a ContextBoundObject object you can “do stuff” but apart from that it seems like you're out of luck. Even passing the current instance as a constructor argument to your attribute (so you could hook in to events and the like) doesn't work either (if anybody knows different please let me know). Somewhat disheartened I fired up
IronPython to have a very belated play around with that. IronPython is cool, and I certainly plan to figure out how to add a “python interactive console” to winforms apps. Next thing I did (somewhat out of the blue) was check Jon Lam's site
IUnknown.com. I had been talking to somebody about the IUnknown COM interface a couple of days before and it had reminded me of Jon's site - what do you think I found there? Some
code on method interception written in Python.