jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
10.91k stars 1.16k forks source link

Calling AddMediatR multiple times? #916

Closed maranmaran closed 1 year ago

maranmaran commented 1 year ago

Hello, couldn't filter out an answer for myself quickly.

Can we call AddMediatR multiple times, say once per assembly?

AutoMapper for example allowed to do that in this change https://github.com/AutoMapper/AutoMapper.Extensions.Microsoft.DependencyInjection/pull/135

From my perspective it's quite convenient, so far I've only seen one-place-all registration whereas that's possible and not a huge problem to manage I'd still like the flexibility

jbogard commented 1 year ago

You should be able to, the core registrations (IMediator etc.) are all done via TryAdd.

jbogard commented 1 year ago

I also added an overload that takes the MediatrServiceConfiguration directly so you can pass that object around to your other libraries and then call AddMediatR once.