views:

160

answers:

1

Say I have an event defined in an interface.

I then have many classes that implement that interface.

The creation of these classes is managed by StructureMap.

Now say I have one delegate that I want to use as the event handler for ALL of these newly created instances.

Is there a way to tell StructureMap to append an event handler to objects it creates?

(NOTE: My current solution is to create a Notifier class and pass that in through the constructor, which gets the job done, but I'm curious if I can eliminate the middleman.)

+1  A: 

If you take a look at http://structuremap.sourceforge.net/Interception.htm there is an explanation to EnrichWith()
Add the the event handler and return the original object and you should have what you want.

Mene
And I thought I had read every page of the docs. Thanks, this looks like it'll do the trick.
roufamatic