Example #1
0
        /// <summary>
        /// Returns a configured ServiceCollection.
        /// </summary>
        public ServiceCollection Create()
        {
            ValidateConfigurations();

            var services = new ServiceCollection();

            services.AddLogging(_loggingConfig);

            var dataPath = new DataDirectoryPath(_rootDataPath);

            var throttle = new WebRequestThrottle(
                _webRequestConfig.ThrottleMilliseconds,
                _webRequestConfig.RandomizedThrottle);

            var programOptions = _programOptions ?? new ProgramOptions();

            services
            .AddScoped(sp => dataPath)
            .AddScoped(sp => _webRequestConfig)
            .AddScoped(sp => throttle)
            .AddScoped <LatestWeekValue>()
            .AddScoped <AvailableWeeksValue>()
            .AddScoped <ProgramOptions>(sp => programOptions)
            .AddScoped <IDatabaseProvider>(sp =>
            {
                var logger = sp.GetRequiredService <IAppLogger>();
                return(_dbProviderFactory(logger));
            })
            .AddScoped <IWebRequestClient, WebRequestClient>()
            .AddCoreDataSources()
            .AddAsyncLazyCache();

            return(services);
        }
Example #2
0
 public GetTeamWeekStats(
     IAppLogger logger,
     ITeamWeekStatsSource source,
     IWeekMatchupsCache weekMatchupsCache,
     WebRequestThrottle throttle)
     : base(logger, "Get Team Week Stats")
 {
     _source            = source;
     _weekMatchupsCache = weekMatchupsCache;
     _throttle          = throttle;
 }
Example #3
0
 public FetchPlayersStage(
     IAppLogger logger,
     IDatabaseProvider dbProvider,
     WebRequestThrottle throttle,
     IPlayerAddSource playerAddSource)
     : base(logger, "Fetch Players")
 {
     _logger          = logger;
     _dbProvider      = dbProvider;
     _throttle        = throttle;
     _playerAddSource = playerAddSource;
 }