// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("localhost", builder => { builder .WithOrigins("http://localhost:4200") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); }); services.AddDbContext <AppDbContext>(options => options.UseSqlServer(ConnectionBuilderHelper.GetDefaultConnectionString())); var rabbitMq = ConnectionBuilderHelper.BuildDefault().GetSection(nameof(RabbitMq)).Get <RabbitMq>(); services.AddSingleton <IRabbitMqService>(options => { var rabbitMqService = new RabbitMqService(rabbitMq); rabbitMqService.Start(); return(rabbitMqService); }); services.AddScoped <IFibCalcService, FibCalcService>(); services.AddScoped <IFibDbService, FibDbService>(); services.AddControllers(); }
private void ConfigureServices(IServiceCollection services) { IConfiguration configuration = ConnectionBuilderHelper.BuildDefault(); services.Configure <RabbitMq> (configuration.GetSection(nameof(RabbitMq))); services.AddDbContext <AppDbContext>(options => options.UseSqlServer(configuration["ConnectionString"])); services.AddScoped <IRabbitMqService, RabbitMqService>(); services.AddScoped <IFibCalcService, FibCalcService>(); services.AddScoped <IFibDbService, FibDbService>(); services.AddSingleton <FibonacciCollectionViewModel>(); services.AddSingleton <MainWindow>(); }