Events interception in different modules

Topics: Core, Writing modules
Nov 18, 2011 at 3:19 PM

Hi All,

I've created a couple of modules. These modules expose events and one of them subscribes to events which are exposed by the modules mentioned above. I have already done this. But I've stuck in a problem: I can not figure out how I can fire an events. I looked through the code of bunch of modules (Orchard.Email, Orchard.Core.Contents and Orchard.Email) and I've not understood how I can implement such functionality in my own bunch of modules.

Is there some way to create my own events? Is there some helper classes (let's say like an event aggregator in Prism)?

Thank you in advance!

Nov 18, 2011 at 4:05 PM
Edited Nov 18, 2011 at 4:05 PM

Orchard has an IEventHandler interface, the core modules you've mentioned use this. You just have to create your own class that implements IEventHandler and define your event methods. Then you can inject that class into anywhere in your modules and call the methods, that will fire the event on Orchard's message bus.