// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddLogging(loggingBuilder => loggingBuilder .AddConsole() .SetMinimumLevel(LogLevel.Debug)); services.AddDbContext<SeasonParticipantsDb>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddMvc(x => x.EnableEndpointRouting = false) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddCors(); services.AddSwaggerDocument(); services.Configure<BusSettings>(Configuration.GetSection("ServiceBus")); services.AddTransient<Func<string, IBusClient>>(serviceProvider => key => { switch (key) { case "NewClubSeason": return ServiceBusFactory.GetBus(Enum.Parse<BusHost>(Configuration.GetSection("ServiceBus")["ServiceBusHost"]), Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], Configuration.GetSection("ServiceBus")["NewClubSeasonAssociationTopicName"], Configuration.GetSection("ServiceBus")["NewClubSeasonAssociationSubscriptionName"]); case "NewSeason": return ServiceBusFactory.GetBus(Enum.Parse<BusHost>(Configuration.GetSection("ServiceBus")["ServiceBusHost"]), Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], Configuration.GetSection("ServiceBus")["NewSeasonTopicName"], Configuration.GetSection("ServiceBus")["NewSeasonSubscriptionName"]); default: throw new InvalidOperationException("Specified bus type does not exist!"); } }); }
public void ConfigureServices() { Host.ConfigureServices((_hostcontext, services) => { services.AddSingleton(sp => { return(new BusSettings() { ServiceBusHost = Configuration.GetSection("ServiceBus")["ServiceBusHost"], ServiceBusConnectionString = Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], NewClubSeasonAssociationSubscriptionName = Configuration.GetSection("ServiceBus")["NewSeasonSubscriptionName"], NewClubSeasonAssociationTopicName = Configuration.GetSection("ServiceBus")["NewSeasonTopicName"] }); }); services.AddSingleton(sp => { return(new ApiSettings() { FixturesDbApiRootKey = Configuration.GetSection("API")["FixturesDbApiRootKey"], FixtureClubAppearancesApiPath = Configuration.GetSection("API")["FixtureClubAppearancesApiPath"] }); }); services.AddLogging(loggingBuilder => loggingBuilder .AddConsole() .SetMinimumLevel(LogLevel.Debug)); services.AddTransient(typeof(FixtureHarvester)); services.AddSingleton((ctx) => { return(new HarvestRequestManager(ctx.GetService <ILogger <HarvestRequestManager> >(), Convert.ToInt32(Configuration["MaxRequestsPerSecond"]))); }); services.AddTransient <Func <string, IBusClient> >(serviceProvider => key => { switch (key) { case "NewSeasonPeriod": return(ServiceBusFactory.GetBus(Enum.Parse <BusHost>(Configuration.GetSection("ServiceBus")["ServiceBusHost"]), Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], Configuration.GetSection("ServiceBus")["NewSeasonPeriodTopicName"], Configuration.GetSection("ServiceBus")["NewSeasonPeriodSubscriptionName"])); case "NewSeason": return(ServiceBusFactory.GetBus(Enum.Parse <BusHost>(Configuration.GetSection("ServiceBus")["ServiceBusHost"]), Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], Configuration.GetSection("ServiceBus")["NewSeasonTopicName"], Configuration.GetSection("ServiceBus")["NewSeasonSubscriptionName"])); default: throw new InvalidOperationException("Specified bus type does not exist!"); } }); services.AddScoped <IHostedService, FixtureExtractorSvc>(); }); }
public void ConfigureServices() { Host.ConfigureServices((_hostcontext, services) => { services.AddSingleton(sp => { return(new BusSettings() { ServiceBusHost = Configuration.GetSection("ServiceBus")["ServiceBusHost"], ServiceBusConnectionString = Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], NewClubSeasonAssociationSubscriptionName = Configuration.GetSection("ServiceBus")["NewSeasonSubscriptionName"], NewClubSeasonAssociationTopicName = Configuration.GetSection("ServiceBus")["NewSeasonTopicName"] }); }); services.AddSingleton(sp => { return(new ApiSettings() { SeasonsDbApiRootKey = Configuration.GetSection("API")["SeasonsDbApiRootKey"], ClubSeasonRegistrationsApiPath = Configuration.GetSection("API")["ClubSeasonRegistrationsApiPath"] }); }); services.AddLogging(loggingBuilder => loggingBuilder .AddConsole() .SetMinimumLevel(LogLevel.Debug)); services.AddTransient <IHttpRequestManager, HttpRequestManager>(); services.AddTransient <ICookieInitialiser, CookieInitialiser>(); services.AddTransient <ISeasonParticipantHarvester, SeasonParticipantHarvester>(); //services.AddSingleton<IHarvestRequestManager>((ctx) => //{ // return new HarvestRequestManager(ctx.GetService<ILogger<HarvestRequestManager>>(), // ctx.GetService<HttpRequestManager>(), // Convert.ToInt32(Configuration["MaxRequestsPerSecond"])); //}); services.AddSingleton <IHarvestRequestManager, HarvestRequestManager>(); services.AddSingleton(sp => { return(ServiceBusFactory.GetBus(Enum.Parse <BusHost>(Configuration.GetSection("ServiceBus")["ServiceBusHost"]), Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], Configuration.GetSection("ServiceBus")["NewSeasonTopicName"], Configuration.GetSection("ServiceBus")["NewSeasonSubscriptionName"])); }); services.AddScoped <IHostedService, SeasonParticipantExtractorSvc>(); }); }
public void ConfigureServices() { Host.ConfigureServices((_hostcontext, services) => { services.AddSingleton(sp => { return(new BusSettings() { ServiceBusHost = Configuration.GetSection("ServiceBus")["ServiceBusHost"], ServiceBusConnectionString = Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], NewClubSeasonAssociationSubscriptionName = Configuration.GetSection("ServiceBus")["NewClubSeasonAssociationSubscriptionName"], NewClubSeasonAssociationTopicName = Configuration.GetSection("ServiceBus")["NewClubSeasonAssociationTopicName"] }); }); services.AddSingleton(sp => { return(new ApiSettings() { PlayersDbApiRootKey = Configuration.GetSection("API")["PlayersDbApiRootKey"], PlayerSquadRegistrationsApiPath = Configuration.GetSection("API")["PlayerSquadRegistrationsApiPath"] }); }); services.AddLogging(loggingBuilder => loggingBuilder .AddConsole() .SetMinimumLevel(LogLevel.Debug)); services.AddTransient(typeof(SquadRegistrationHarvester)); services.AddSingleton((ctx) => { return(new HarvestRequestManager(ctx.GetService <ILogger <HarvestRequestManager> >(), Convert.ToInt32(Configuration["MaxRequestsPerSecond"]))); }); services.AddSingleton(sp => { return(ServiceBusFactory.GetBus(Enum.Parse <BusHost>(Configuration.GetSection("ServiceBus")["ServiceBusHost"]), Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], Configuration.GetSection("ServiceBus")["NewClubSeasonAssociationTopicName"], Configuration.GetSection("ServiceBus")["NewClubSeasonAssociationSubscriptionName"])); }); services.AddScoped <IHostedService, SquadRegistrationExtractorSvc>(); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddLogging(); services.AddDbContext <FixtureDb>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddCors(); services.AddSwaggerDocument(); services.Configure <BusSettings>(Configuration.GetSection("ServiceBus")); services.AddSingleton(sp => { return(ServiceBusFactory.GetBus(Enum.Parse <BusHost>(Configuration.GetSection("ServiceBus")["ServiceBusHost"]), Configuration.GetSection("ServiceBus")["ServiceBusConnectionString"], Configuration.GetSection("ServiceBus")["NewFixtureTopicName"], Configuration.GetSection("ServiceBus")["NewFixtureSubscriptionName"])); }); }