Skip to content

Instantly share code, notes, and snippets.

View DanielGilbert's full-sized avatar
🏠
Working from home

Daniel Gilbert DanielGilbert

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am DanielGilbert on github.
  • I am danielgilbert (https://keybase.io/danielgilbert) on keybase.
  • I have a public key whose fingerprint is C384 7A4E 9514 B3EB DD16 B060 485E 8BC2 8D3D 5A7A

To claim this, I am signing this object:

@DanielGilbert
DanielGilbert / MediatRExtensions.cs
Created February 19, 2017 00:02 — forked from rmacfie/MediatRExtensions.cs
Register MediatR handlers in Asp.Net 5 / vNext / Core
namespace Microsoft.AspNet.Builder
{
public static class MediatRExtensions
{
public static IServiceCollection AddMediatR(this IServiceCollection services, params Assembly[] handlerAssemblies)
{
services.AddTransient<IMediator>(x => new Mediator(x.GetService<SingleInstanceFactory>(), x.GetService<MultiInstanceFactory>()));
services.AddTransient<SingleInstanceFactory>(x => t => x.GetRequiredService(t));
services.AddTransient<MultiInstanceFactory>(x => t => x.GetServices(t));