Closed trreeves closed 4 years ago
Go for it! 😁
I haven't played around with ASP.NET Core yet, so I am not really accustomed to its configuration API – but it looks like you have pretty much nailed its style, so I guess this would be a nice addition to the ServiceProvider container adapter.
With the current version of Rebus.ServiceProvider (5.0.4 at the time of writing), it's possible to
// just register a handler type:
services.AddRebusHandler<SomeHandler>();
// register a Func<IServiceProvider, TService>:
services.AddRebusHandler(p => new SomeHandler(p.GetService<SomethingOptional>()));
// auto-register all Rebus handlers found in a specific type's assembly:
services.AutoRegisterHandlersFromAssemblyOf<SomeHandler>();
// auto-register all Rebus handlers found in an assembly:
services.AutoRegisterHandlersFromAssembly(typeof(SomeType).Assembly);
// auto-register all Rebus handlers found in a dynamically loaded assembly:
services.AutoRegisterHandlersFromAssembly("SomeAssembly");
If anything is missing please don't hesitate to comment on this issue 🙂
How about something like the following, to provide more flexibility and discover-ability when registering handlers:
What do you think?