Beispiel #1
0
        public static IRevoConfiguration ConfigureInfrastructure(this IRevoConfiguration configuration,
                                                                 Action <InfrastructureConfigurationSection> action = null)
        {
            configuration.ConfigureCore();
            configuration.UseInMemoryJobs(isActive: null); // activate only if not previously disabled

            var section = configuration.GetSection <InfrastructureConfigurationSection>();

            action?.Invoke(section);

            configuration.ConfigureKernel(c =>
            {
                if (!c.Kernel.GetBindings(typeof(IAsyncEventPipelineConfiguration)).Any())
                {
                    c.Kernel.Bind <IAsyncEventPipelineConfiguration>().ToConstant(section.AsyncEventPipeline);
                }

                if (!c.Kernel.GetBindings(typeof(DatabaseMigrationsConfiguration)).Any())
                {
                    c.Kernel.Bind <DatabaseMigrationsConfiguration>().ToConstant(section.DatabaseMigrations);
                }

                c.LoadModule(new DatabaseMigrationsModule(section.DatabaseMigrations));

                if (section.EnableSagas)
                {
                    c.LoadModule <SagasModule>();
                }
            });

            return(configuration);
        }
Beispiel #2
0
        public static IRevoConfiguration ConfigureInfrastructure(this IRevoConfiguration configuration,
                                                                 AsyncEventPipelineConfiguration asyncEventPipelineConfiguration = null,
                                                                 Action <InfrastructureConfigurationSection> advancedAction      = null)
        {
            configuration.ConfigureCore();

            var section = configuration.GetSection <InfrastructureConfigurationSection>();

            section.AsyncEventPipeline = asyncEventPipelineConfiguration ?? section.AsyncEventPipeline;

            advancedAction?.Invoke(section);

            configuration.ConfigureKernel(c =>
            {
                if (!c.Kernel.GetBindings(typeof(IAsyncEventPipelineConfiguration)).Any())
                {
                    c.Kernel.Bind <IAsyncEventPipelineConfiguration>().ToConstant(section.AsyncEventPipeline);
                }

                if (section.EnableSagas)
                {
                    c.LoadModule <SagasModule>();
                }
            });

            return(configuration);
        }