public Task InitializeAsync(IServiceProvider provider)
        {
            var confProvider = provider.GetRequiredService <IConfiguration>();

            if (Hostname == null)
            {
                Hostname = confProvider["httpConfig:defaultHostname"];
            }
            var httpConfSection = confProvider.GetSection("httpConfig");

            if (httpConfSection != null)
            {
                string uname, pw;
                if ((uname = httpConfSection.GetSection("authentication")["username"]) != null && (pw = httpConfSection.GetSection("authentication")["password"]) != null)
                {
                    Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(uname + ':' + pw)));
                }
                string usragentheader;
                if ((usragentheader = httpConfSection["useragent"]) != null)
                {
                    Client.DefaultRequestHeaders.Add("User-Agent", usragentheader);
                }
            }

            _roundInferenceService = provider.GetService <ICompetitionRoundLogicService>() ?? _roundInferenceService;

            // optionally, attempt to deduce categories
            _categoryProvider = provider.GetService <IExternalCategoryProviderService>();

            RateLimiter = provider.GetService <IRateLimitProvider>() ?? new NoneRateLimitProvider();

            return(Task.CompletedTask);
        }
        public Task InitializeAsync(IServiceProvider provider, IConfigurationSection httpConfSection)
        {
            _httpConfiguration = httpConfSection;
            if (Hostname == null)
            {
                Hostname = httpConfSection["defaultHostname"];
            }

            int forcedCompetitionRound = 0;

            if (httpConfSection != null)
            {
                string uname, pw;
                if ((uname = httpConfSection.GetSection("authentication")["username"]) != null && (pw = httpConfSection.GetSection("authentication")["password"]) != null)
                {
                    Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(uname + ':' + pw)));
                }
                string usragentheader;
                if ((usragentheader = httpConfSection["useragent"]) != null)
                {
                    Client.DefaultRequestHeaders.Add("User-Agent", usragentheader);
                }
                forcedCompetitionRound = httpConfSection.GetValue <int>("forceRound");
            }

            _roundInferenceService = provider.GetService <ICompetitionRoundLogicService>() ?? _roundInferenceService;

            if (forcedCompetitionRound > 0 || _roundInferenceService == null)
            {
                _roundInferenceService = new PreconfiguredRoundPassthroughCompetitionRoundLogicService((CompetitionRound)forcedCompetitionRound, _roundInferenceService);
            }

            // optionally, attempt to deduce categories
            _categoryProvider = provider.GetService <IExternalCategoryProviderService>();

            RateLimiter = provider.GetService <IRateLimitProvider>() ?? new NoneRateLimitProvider();

            return(Task.CompletedTask);
        }