Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto wire event handlers with StructureMap?

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.)

like image 583
roufamatic Avatar asked Nov 15 '22 13:11

roufamatic


1 Answers

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.

like image 144
Mene Avatar answered Dec 18 '22 18:12

Mene