I'm trying to subscribe to an event using Simple Injector. My class has:
public class MyClass
{
public event Action<MyClass> SomeEvent;
//...
}
With Ninject, it can be done with OnActivation()
:
Bind<MyClass>().ToSelf()
.OnActivation((context, myObj) =>
{
myObj.SomeEvent += MyStaticEventHandler.Handle; // for static
// or...
myObj.SomeEvent += context.Kernel.Get<MyEventHandler>().Handle; // for non-static
});
How is this done with Simple Injector? I tried looking around, but only found content on IEventHandler
/ICommandHandler
implementations, none using C# events.