예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IHostedService, MatchDataCollectionService>();
            services.AddSingleton <ILogging, Logging>();
            services.AddSingleton <IThrottledRequestHelper, ThrottledRequestHelper>();

            services.AddSingleton <IRiotApi>(RiotApi.GetDevelopmentInstance("RGAPI-ae48adb7-5934-4272-8afb-7d8f9aa6cf4a"));
            services.AddSingleton <IStaticDataEndpoints>(StaticDataEndpoints.GetInstance("RGAPI-ae48adb7-5934-4272-8afb-7d8f9aa6cf4a"));

            services.AddTransient <ISummonerRepository, SummonerRepository>();
            services.AddTransient <IBasicMatchupInformationRepository, BasicMatchupInformationRepository>();
            services.AddTransient <ICachedCalculatedMatchupInformationRepository, CachedCalculatedMatchupInformationRepository>();
            services.AddTransient <IChampionStaticDataRepository, ChampionStaticDataRepository>();
            services.AddTransient <IItemStaticDataRepository, ItemStaticDataRepository>();
            services.AddTransient <ISummonerSpellStaticDataRepository, SummonerSpellStaticDataRepository>();
            services.AddTransient <IRunesStaticDataRepository, RunesStaticDataRepository>();
            services.AddTransient <IMatchControllerUtils, MatchControllerUtils>();


            var dbConn = @"Server=(localdb)\mssqllocaldb;Database=LccDatabase;Trusted_Connection=True;ConnectRetryCount=0";

            services.AddDbContext <LccDatabaseContext>(options => options.UseSqlServer(dbConn));

            services.AddMvc();
        }
예제 #2
0
        /// <summary>
        /// Dependency injection constructor
        /// </summary>
        /// <param name="rateLimitedRequester">Rate limited requester for all endpoints except the static endpoint.</param>
        /// <param name="staticEndpointProvider">The static endpoint provider.</param>
        /// <param name="cache">The cache.</param>
        /// <exception cref="ArgumentNullException">
        /// rateLimitedRequester
        /// or
        /// staticEndpointProvider
        /// </exception>
        public RiotApi(IRateLimitedRequester rateLimitedRequester, IRequester requester, IStaticEndpointProvider staticEndpointProvider,
                       ICache cache = null)
        {
            if (rateLimitedRequester == null)
            {
                throw new ArgumentNullException(nameof(rateLimitedRequester));
            }
            if (staticEndpointProvider == null)
            {
                throw new ArgumentNullException(nameof(staticEndpointProvider));
            }

            _cache = cache ?? new PassThroughCache();

            Summoner        = new SummonerEndpoint(rateLimitedRequester, _cache);
            Champion        = new ChampionEndpoint(rateLimitedRequester);
            League          = new LeagueEndpoint(rateLimitedRequester);
            Match           = new MatchEndpoint(rateLimitedRequester, _cache);
            Spectator       = new SpectatorEndpoint(rateLimitedRequester);
            ChampionMastery = new ChampionMasteryEndpoint(rateLimitedRequester);
            ThirdParty      = new ThirdPartyEndpoint(rateLimitedRequester);

            StaticData = new StaticDataEndpoints(staticEndpointProvider);
            Status     = new StatusEndpoint(requester);
        }
예제 #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IHostedService, MatchDataCollectionService>();
            services.AddSingleton <IThrottledRequestHelper, ThrottledRequestHelper>();
            services.AddScoped <IStaticDataCollectionService, StaticDataCollectionService>();

            services.AddSingleton <IRiotApi>(RiotApi.GetDevelopmentInstance(RiotApiKey));
            services.AddSingleton <IStaticDataEndpoints>(StaticDataEndpoints.GetInstance(RiotApiKey));

            services.AddScoped <IMatchProvider, MatchProvider>();

            var dbConn = @"Server=(localdb)\mssqllocaldb;Database=LccDatabase;Trusted_Connection=True;ConnectRetryCount=0";

            services.AddDbContext <DatabaseContext>(options => options.UseSqlServer(dbConn));

            services.AddMvc();

            services.AddMvcCore()
            .AddAuthorization()
            .AddJsonFormatters();

            services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority            = "http://localhost:5000";
                options.RequireHttpsMetadata = false;

                options.ApiName = "LccApi";
            });
        }
예제 #4
0
        private RiotApi(string apiKey, IDictionary <TimeSpan, int> rateLimits)
        {
            Requesters.RiotApiRequester = new RateLimitedRequester(apiKey, rateLimits);
            var requester = Requesters.RiotApiRequester;

            Summoner        = new SummonerEndpoint(requester, _cache);
            Champion        = new ChampionEndpoint(requester);
            Masteries       = new MasteriesEndpoint(requester);
            Runes           = new RunesEndpoint(requester);
            League          = new LeagueEndpoint(requester);
            Match           = new MatchEndpoint(requester, _cache);
            Spectator       = new SpectatorEndpoint(requester);
            ChampionMastery = new ChampionMasteryEndpoint(requester);
            ThirdParty      = new ThirdPartyEndpoint(requester);
            Static          = StaticDataEndpoints.GetInstance(apiKey, true);
        }
예제 #5
0
        private RiotApi(string apiKey, IDictionary <TimeSpan, int> rateLimits, ICache cache)
        {
            _cache = cache ?? throw new ArgumentNullException(nameof(cache));
            Requesters.RiotApiRequester   = new RateLimitedRequester(apiKey, rateLimits);
            Requesters.StaticApiRequester = new Requester(apiKey);
            var requester = Requesters.RiotApiRequester;

            Summoner        = new SummonerEndpoint(requester, _cache);
            Champion        = new ChampionEndpoint(requester);
            League          = new LeagueEndpoint(requester);
            Match           = new MatchEndpoint(requester, _cache);
            Spectator       = new SpectatorEndpoint(requester);
            ChampionMastery = new ChampionMasteryEndpoint(requester);
            ThirdParty      = new ThirdPartyEndpoint(requester);

            StaticData = new StaticDataEndpoints(Requesters.StaticApiRequester, _cache);
            Status     = new StatusEndpoint(Requesters.StaticApiRequester);
        }
예제 #6
0
        public StaticRiotApiTest()
        {
            var cache = new Cache();

            _api = StaticDataEndpoints.GetInstance(Requester.ApiKey, true);
        }