How is Container installed in this static class?
You will need to install it during application launch:
DomainEvents.Container = kernel;
What will be the Ninject syntax for resolving all event handlers:
You can do this, for example:
Container.Get<IEnumerable<Handles<T>>>())
The Udi class static DomainEvents is an implementation of the environment context template. Ambient context is a template that is used only in a limit on the number of scenarios. In this case, I would prefer to use dependency injection to insert the IDomainEvents abstraction into the code that she needs, rather than the code dependent on a static instance.
However, the problem is that the objects in your domain will require a dependency on IDomainEvents , and constructor injection is (possibly) impossible. The trick is to use the injection method in this case.
In other words, use the constructor injection to inject IDomainEvents into command or service handlers (or what you ever call your business logic, which uses methods on domain objects), and pass this dependency to the domain object when you call the method that needed (injection method).
source share