示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            IEventFlowOptions eventFlowOptions = EventFlowOptions.New;

            eventFlowOptions.AddAspNetCoreMetadataProviders();

            services.AddTransient <IAccountApplicationService, AccountApplicationService>();
            services.AddTransient <IAccountQueryService, AccountQueryService>();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new Info {
                    Title = "Account Balance", Version = "v1"
                });
                c.DescribeAllEnumsAsStrings();
            });
            var containerBuilder = new ContainerBuilder();
            var container        = EventFlowOptions.New
                                   .UseAutofacContainerBuilder(containerBuilder)
                                   .AddDefaults(AccountDomainHelpers.Assembly)
                                   .AddDefaults(AccountApplicationHelpers.Assembly)
                                   .UseInMemoryReadStoreFor <AccountReadModel>()
                                   .AddAspNetCoreMetadataProviders();

            containerBuilder.RegisterType <AccountReadStore>().As <IAccountReadStore>().SingleInstance();
            containerBuilder.Populate(services);
            return(new AutofacServiceProvider(containerBuilder.Build()));
        }