예제 #1
0
        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());
        }
예제 #2
0
        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());
        }