public IBus CreateBus(Action <IHandlerRegistry> configureHandlers, Func <RebusConfigurer, RebusConfigurer> configureBus, out IActivatedContainer container) { var containerBuilder = new ContainerBuilder(); configureHandlers(new HandlerRegistry(containerBuilder)); new AutofacHandlerActivator(containerBuilder, (conf, con) => configureBus(conf), startBus: true, enablePolymorphicDispatch: true); var autofacContainer = containerBuilder.Build(); container = new ActivatedContainer(autofacContainer); return(container.ResolveBus()); }
public IBus CreateBus(Action <IHandlerRegistry> handlerConfig, Func <RebusConfigurer, RebusConfigurer> configureBus, out IActivatedContainer container) { var services = new ServiceCollection(); handlerConfig.Invoke(new HandlerRegistry(services)); services.AddRebus(configureBus); var provider = services.BuildServiceProvider(); container = new ActivatedContainer(provider); provider.UseRebus(); return(container.ResolveBus()); }