Esempio n. 1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(_configuration.Bind <ConfigurationBase>());
            services.AddSingleton(_configuration);
            services.AddSingleton(_logger);

            services.AddMvc().AddJsonOptions(opts =>
            {
                opts.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });
            services.AddSignalR().AddJsonProtocol(opts =>
            {
                opts.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });
            services.AddAntiforgery();
            services.AddFactorinoAuthentication(_configuration);
            services.AddSwaggerGen(opts =>
            {
                opts.SwaggerDoc("v1", new Info {
                    Title = "Factorino API", Version = "v1"
                });
            });

            services.AddDbContext <ReadModelDbContext>(opts =>
            {
                // We're disabling tracking here, because the webapp will never write to db
                ReadModelDbContext.ConfigureBuilder(opts, _configuration, disableTracking: true);
            });

            services.AddScoped <IPlayerRepository, PlayerRepository>();
            services.AddScoped <IFactoryRepository, FactoryRepository>();
            services.AddScoped <DeedRepository, DeedRepository>();
            services.AddScoped <ICorporationRepository, CorporationRepository>();
            services.AddScoped <IEntityRepository, EntityRepository>();
            services.AddScoped <IMarketRepository, MarketRepository>();
            services.AddScoped <IShippingRepository, ShippingRepository>();
            services.AddScoped <IEventStore, KafkaProducer>();

            services.AddHostedService <EventStreamMediator>();
        }