Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "My API", Version = "v1"
                });
            });
            var containerBuilder = new ContainerBuilder();

            var container = EventFlowOptions.New
                            .UseAutofacContainerBuilder(containerBuilder)
                            .AddAspNetCoreMetadataProviders()
                            .AddEvents(typeof(ExampleEvent))
                            .AddCommands(typeof(ExampleCommand))
                            .AddCommandHandlers(typeof(ExampleCommandHandler))
                            .UseConsoleLog()
                            .UseFilesEventStore(FilesEventStoreConfiguration.Create("./evt-store"))
                            .UseInMemoryReadStoreFor <ExampleReadModel>();

            containerBuilder.Populate(services);

            return(new AutofacServiceProvider(containerBuilder.Build()));
        }
Example #2
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterApiControllers(typeof(Startup).Assembly).InstancePerRequest();
            containerBuilder.RegisterType <CommandPublishMiddleware>().InstancePerRequest();

            var storePath = Path.Combine(
                Path.GetTempPath(),
                Guid.NewGuid().ToString());

            var container = EventFlowOptions.New
                            .UseAutofacContainerBuilder(containerBuilder)
                            .AddDefaults(EventFlowTestHelpers.Assembly)
                            .AddOwinMetadataProviders()
                            .UseFilesEventStore(FilesEventStoreConfiguration.Create(storePath))
                            .RegisterServices(f => f.Register(r => new DirectoryCleaner(storePath), Lifetime.Singleton))
                            .CreateContainer(false);

            container.Resolve <DirectoryCleaner>();

            var config = new HttpConfiguration
            {
                DependencyResolver       = new AutofacWebApiDependencyResolver(container),
                IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly,
            };

            config.MapHttpAttributeRoutes();
            config.Formatters.Remove(config.Formatters.XmlFormatter);
            config.Services.Add(typeof(IExceptionLogger), new LogProviderExceptionLogger(container.Resolve <ILog>()));

            appBuilder.UseAutofacMiddleware(container);
            appBuilder.UseAutofacWebApi(config);
            appBuilder.UseWebApi(config);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            services.AddFluentValidation(cfg =>
            {
                cfg.RegisterValidatorsFromAssemblyContaining <Startup>();
            });

            services.AddEventFlow(ef =>
            {
                ef.AddAspNetCore()
                .AddDefaults(typeof(Startup).Assembly)
                .UseConsoleLog()
                .UseInMemoryReadStoreFor <DriverReadModel>()
                .UseInMemorySnapshotStore()
                .UseFilesEventStore(FilesEventStoreConfiguration.Create("d:\\ES"))
                .RegisterServices(s =>
                {
                    s.Register <IDriverQueryService, DriverQueryService>();
                    s.Register <IEntityGeneratorService, EntityGeneratorService>();
                });

                //.AddEvents(typeof(DriverCreatedEvent))
                //.AddCommands(typeof(AddDriverCommand))
                //.AddCommandHandlers(typeof(AddDriverCommandHandler))
                //.PublishToRabbitMq(RabbitMqConfiguration.With(new Uri(env.RabbitMqConnection)))
            });
        }
Example #4
0
        private void UseFileSystemBasedStore(string storePath)
        {
            var fileEventStoreConfiguration = FilesEventStoreConfiguration.Create(storePath);

            this.options.UseFilesEventStore(fileEventStoreConfiguration)
            .AddQueryHandlers(Simulator.SimulatorAssembly)
            .UseInMemoryReadStoreFor <TreatmentRoomReadModel> ()
            .UseInMemoryReadStoreFor <TreatmentMachineReadModel>()
            .UseInMemoryReadStoreFor <DoctorReadModel>()
            .UseInMemoryReadStoreFor <PatientReadModel>()
            .UseInMemoryReadStoreFor <ConsultationReadModel>();
        }
        public void SetUp()
        {
            var codeBase = ReflectionHelper.GetCodeBase(GetType().Assembly);
            var filesEventStoreDirectory = Path.GetFullPath(Path.Combine(codeBase, "..", "..", "TestData", "FilesEventStore"));

            _resolver = EventFlowOptions.New
                        .UseFilesEventStore(FilesEventStoreConfiguration.Create(filesEventStoreDirectory))
                        .AddEvents(EventFlowTestHelpers.Assembly)
                        .AddCommandHandlers(EventFlowTestHelpers.Assembly)
                        .CreateResolver();

            _commandBus = _resolver.Resolve <ICommandBus>();
            _eventStore = _resolver.Resolve <IEventStore>();
        }
        public void SetUp()
        {
            var codeBase = ReflectionHelper.GetCodeBase(GetType().Assembly);
            var filesEventStoreDirectory = Path.GetFullPath(Path.Combine(codeBase, "..", "..", "..", "TestData", "FilesEventStore"));

            _resolver = EventFlowOptions.New
                        .UseFilesEventStore(FilesEventStoreConfiguration.Create(filesEventStoreDirectory))
                        .AddEvents(EventFlowTestHelpers.Assembly)
                        .AddCommandHandlers(EventFlowTestHelpers.Assembly)
                        .RegisterServices(sr => sr.Register <IScopedContext, ScopedContext>(Lifetime.Scoped))
                        .CreateResolver();

            _commandBus     = _resolver.Resolve <ICommandBus>();
            _aggregateStore = _resolver.Resolve <IAggregateStore>();
        }
        public void SetUp()
        {
            var codeBase = ReflectionHelper.GetCodeBase(GetType().Assembly);
            var filesEventStoreDirectory = Path.GetFullPath(Path.Combine(codeBase, "..", "..", "..", "TestData", "FilesEventStore"));

            _serviceProvider = EventFlowOptions.New()
                               .UseFilesEventPersistence(FilesEventStoreConfiguration.Create(filesEventStoreDirectory))
                               .AddEvents(EventFlowTestHelpers.Assembly)
                               .AddCommandHandlers(EventFlowTestHelpers.Assembly)
                               .RegisterServices(sr => sr.AddScoped <IScopedContext, ScopedContext>())
                               .ServiceCollection.BuildServiceProvider();

            _commandBus     = _serviceProvider.GetRequiredService <ICommandBus>();
            _aggregateStore = _serviceProvider.GetRequiredService <IAggregateStore>();
        }
Example #8
0
        protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
        {
            var storePath = Path.Combine(
                Path.GetTempPath(),
                Guid.NewGuid().ToString());

            Directory.CreateDirectory(storePath);

            var resolver = eventFlowOptions
                           .UseFilesEventStore(FilesEventStoreConfiguration.Create(storePath))
                           .CreateResolver();

            _configuration = resolver.Resolve <IFilesEventStoreConfiguration>();

            return(resolver);
        }
Example #9
0
        protected override IServiceProvider Configure(IEventFlowOptions eventFlowOptions)
        {
            var storePath = Path.Combine(
                Path.GetTempPath(),
                Guid.NewGuid().ToString());

            Directory.CreateDirectory(storePath);

            var serviceProvider = eventFlowOptions
                                  .UseFilesEventPersistence(FilesEventStoreConfiguration.Create(storePath))
                                  .ServiceCollection.BuildServiceProvider();

            _configuration = serviceProvider.GetRequiredService <IFilesEventStoreConfiguration>();

            return(serviceProvider);
        }
Example #10
0
            public override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
            {
                var storePath = Path.Combine(
                    Path.GetTempPath(),
                    Guid.NewGuid().ToString());

                Directory.CreateDirectory(storePath);

                var resolver = eventFlowOptions
                               .UseInMemoryReadStoreFor <InMemoryTestAggregateReadModel>()
                               .UseFilesEventStore(FilesEventStoreConfiguration.Create(storePath))
                               .CreateResolver();

                _configuration      = resolver.Resolve <IFilesEventStoreConfiguration>();
                _readModelPopulator = resolver.Resolve <IReadModelPopulator>();
                _queryProcessor     = resolver.Resolve <IQueryProcessor>();

                return(resolver);
            }
 internal static void ConfigureEventFlow(this IEventFlowOptions eventFlowOptions,
                                         IConfiguration configuration,
                                         ContainerBuilder containerBuilder)
 {
     eventFlowOptions
     .UseAutofacContainerBuilder(containerBuilder)
     .AddAspNetCore(c => c
                    .RunBootstrapperOnHostStartup()
                    .UseMvcJsonOptions()
                    .UseModelBinding()
                    .AddUserClaimsMetadata()
                    .UseLogging()
                    .AddMetadataProviders()
                    .UseModelBinding()
                    .AddUriMetadata()
                    .AddRequestHeadersMetadata())
     .RegisterModules()
     .UseFilesEventStore(FilesEventStoreConfiguration.Create("./evt-store"))
     .UseConsoleLog();
 }
Example #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddLogging(logging => logging
                                .AddConsole()
                                .SetMinimumLevel(LogLevel.Debug));

            services
            .AddEventFlow(o => o
                          .AddDefaults(typeof(EmployeeId).Assembly)
                          .UseFilesEventStore(FilesEventStoreConfiguration.Create("./evt-store"))
                          //.UseInMemoryReadStoreFor<EmployeeReadModel>()
                          .CustomReadModel()
                          .ConfigureJson(j => j
                                         .AddSingleValueObjects())
                          .AddAspNetCore(c => c
                                         .RunBootstrapperOnHostStartup()
                                         .UseMvcJsonOptions()
                                         .UseModelBinding()
                                         .AddUserClaimsMetadata()
                                         .UseLogging()
                                         ));
        }
        private IFilesEventStoreConfiguration ConfigurePath(string storePath)
        {
            var fullPath = Path.Combine(_storeRootPath, storePath);

            return(FilesEventStoreConfiguration.Create(fullPath));
        }