Exemplo n.º 1
0
        // 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(AllowAllSpecificOrigins,
                                  builder =>
                {
                    builder
                    .AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddControllers();

            // TODO: convention based
            var appInfoOptions = new ApplicationInfoOptions();

            Configuration.GetSection(ApplicationInfoOptions.SectionName).Bind(appInfoOptions);
            services.AddSingleton(appInfoOptions);

            var lyricsApiOptions = new LyricsApiOptions();

            Configuration.GetSection(LyricsApiOptions.SectionName).Bind(lyricsApiOptions);
            services.AddSingleton(lyricsApiOptions);

            services.AddTransient <IArtistService, MusicBrainzService>();
            services.AddTransient <ILyricsService, LyricsService>();
            services.AddTransient <IWordCounterService, WordCounterService>();
            services.AddTransient <IAggregatorProcess, AggregatorProcess>();

            services.AddSingleton(new HttpClient());
            services.AddSingleton <ICacheService, CacheService>();
        }
Exemplo n.º 2
0
 public LyricsService(
     HttpClient httpClient,
     LyricsApiOptions lyricsApiOptions)
 {
     _httpClient       = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     _lyricsApiOptions = lyricsApiOptions ?? throw new ArgumentNullException(nameof(httpClient));
 }