protected ContainerBuilderBusRegistrationConfigurator(ContainerBuilder builder, AutofacContainerRegistrar registrar)
            : base(registrar)
        {
            Builder    = builder;
            _registrar = registrar;
            RiderTypes = new HashSet <Type>();

            ScopeName = "message";

            builder.RegisterType <BusDepot>()
            .As <IBusDepot>()
            .SingleInstance();

            builder.Register(GetCurrentSendEndpointProvider)
            .As <ISendEndpointProvider>()
            .InstancePerLifetimeScope();

            builder.Register(GetCurrentPublishEndpoint)
            .As <IPublishEndpoint>()
            .InstancePerLifetimeScope();


            builder.Register(CreateConsumerScopeProvider)
            .As <IConsumerScopeProvider>()
            .SingleInstance()
            .IfNotRegistered(typeof(IConsumerScopeProvider));

            builder.Register(context => new AutofacConfigurationServiceProvider(context.Resolve <ILifetimeScope>()))
            .As <IConfigurationServiceProvider>()
            .SingleInstance()
            .IfNotRegistered(typeof(IConfigurationServiceProvider));
        }
        ContainerBuilderRegistrationConfigurator(ContainerBuilder builder, AutofacContainerRegistrar registrar)
            : base(registrar)
        {
            _builder   = builder;
            _registrar = registrar;

            ScopeName = "message";

            builder.Register(CreateSendScopeProvider)
            .As <ISendScopeProvider>()
            .SingleInstance();

            builder.Register(CreatePublishScopeProvider)
            .As <IPublishScopeProvider>()
            .SingleInstance();

            builder.Register(CreateConsumerScopeProvider)
            .As <IConsumerScopeProvider>()
            .SingleInstance();

            builder.Register(CreateSagaRepositoryFactory)
            .As <ISagaRepositoryFactory>()
            .SingleInstance();

            builder.Register(context => new AutofacConfigurationServiceProvider(context.Resolve <ILifetimeScope>()))
            .As <IConfigurationServiceProvider>()
            .SingleInstance();

            builder.RegisterInstance <IRegistrationConfigurator>(this);

            builder.Register(provider => CreateRegistration(provider.Resolve <IConfigurationServiceProvider>()))
            .As <IRegistration>()
            .SingleInstance();
        }
        ContainerBuilderMediatorConfigurator(ContainerBuilder builder, AutofacContainerRegistrar registrar)
            : base(registrar)
        {
            IMediatorRegistrationContext CreateRegistrationContext(IComponentContext context)
            {
                var registration = CreateRegistration(context.Resolve <IConfigurationServiceProvider>());

                return(new MediatorRegistrationContext(registration));
            }

            Builder    = builder;
            _registrar = registrar;

            ScopeName = "message";

            builder.Register(CreateConsumerScopeProvider)
            .As <IConsumerScopeProvider>()
            .SingleInstance()
            .IfNotRegistered(typeof(IConsumerScopeProvider));

            builder.Register(context => new AutofacConfigurationServiceProvider(context.Resolve <ILifetimeScope>()))
            .As <IConfigurationServiceProvider>()
            .SingleInstance()
            .IfNotRegistered(typeof(IConfigurationServiceProvider));

            builder.Register(MediatorFactory)
            .As <IMediator>()
            .SingleInstance();

            builder.Register(CreateRegistrationContext)
            .As <IMediatorRegistrationContext>()
            .SingleInstance();
        }
Exemplo n.º 4
0
        ContainerBuilderBusRegistrationConfigurator(ContainerBuilder builder, AutofacContainerRegistrar registrar)
            : base(registrar)
        {
            IBusRegistrationContext CreateRegistrationContext(IComponentContext context)
            {
                var provider  = context.Resolve <IConfigurationServiceProvider>();
                var busHealth = context.Resolve <BusHealth>();

                return(new BusRegistrationContext(provider, busHealth, Endpoints, Consumers, Sagas, ExecuteActivities, Activities));
            }

            Builder     = builder;
            _registrar  = registrar;
            _riderTypes = new HashSet <Type>();

            ScopeName = "message";

            builder.RegisterType <BusDepot>()
            .As <IBusDepot>()
            .SingleInstance();

            Builder.Register(context => new BusHealth())
            .As <BusHealth>()
            .As <IBusHealth>()
            .SingleInstance();

            Builder.Register(GetCurrentSendEndpointProvider)
            .As <ISendEndpointProvider>()
            .InstancePerLifetimeScope();

            Builder.Register(GetCurrentPublishEndpoint)
            .As <IPublishEndpoint>()
            .InstancePerLifetimeScope();

            Builder.Register(context => ClientFactoryProvider(context.Resolve <IConfigurationServiceProvider>(), context.Resolve <IBus>()))
            .As <IClientFactory>()
            .SingleInstance();

            builder.Register(CreateConsumerScopeProvider)
            .As <IConsumerScopeProvider>()
            .SingleInstance()
            .IfNotRegistered(typeof(IConsumerScopeProvider));

            builder.Register(context => new AutofacConfigurationServiceProvider(context.Resolve <ILifetimeScope>()))
            .As <IConfigurationServiceProvider>()
            .SingleInstance()
            .IfNotRegistered(typeof(IConfigurationServiceProvider));

            builder.Register(CreateRegistrationContext)
            .As <IBusRegistrationContext>()
            .SingleInstance();
        }