Configuration
Once installed, you will need to configure Mediate in your app’s Startup class inside the ConfigureServices method.
For this, Mediate provides some helper methods as IServiceCollection extension methods.
Mediate services configuration
First, you have to configure Mediate’s basic services.
You can use one of the following methods:
AddMediateRegisters the mediator service with the default providers as scoped services. See Providers for details.
AddMediateCoreRegisters the mediator service as a scoped service and returns a builder object that has a number of helper methods to configure Mediate. See Advanced configuration for details.
Event dispatching strategy configuration
Second, you have to configure the event dispatch strategy that you want to use.
You can use one of the following methods:
AddMediateSequentialEventDispatchStrategyRegisters the sequential event dispatch strategy as a scoped service. See SequentialEventDispatchStrategy for details.
AddMediateParallelEventDispatchStrategyRegisters the parallel event dispatch strategy as a scoped service. See ParallelEventDispatchStrategy for details.
AddMediateCustomDispatchStrategyRegisters a custom event dispatch strategy as a scoped service. You can also use
AddMediateCustomDispatchStrategy(ServiceLifetime)to control the registration lifetime in the DI container. See Custom Event Dispatch Strategy for details.
Automatic handlers and middlewares registration
Third, you have to register your handlers and middlewares with the container.
You can do this manually or use the helper method AddMediateClassesFromAssembly(Assembly).
This method scans the given assembly and registers the found classes as transient services. (open generics handlers and middlewares included).