Beispiel #1
0
        protected BaseService(
            ILeagueApiConfiguration apiConfiguration,
            VersionEnum version,
            string prefix,
            bool isLimitedByRateLimit = true)
        {
            if (apiConfiguration == null)
            {
                throw new ArgumentNullException("apiConfiguration");
            }
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix");
            }

            _apiConfiguration = apiConfiguration;

            _version = version;
            Prefix   = prefix;
            _isLimitedByRateLimit = isLimitedByRateLimit;

            if (!LastRequests.ContainsKey(_apiConfiguration.Key))
            {
                LastRequests[_apiConfiguration.Key] = new List <DateTime>();
            }

            AutoMapperService = new AutoMapperService(apiConfiguration);

            AutoMapperService.CreateMap <long, DateTime>()
            .ConvertUsing(x => new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(x));
        }
Beispiel #2
0
        protected async Task <TDestination> GetResponseAsync <TSource, TDestination>(Uri uri)
            where TSource : class
        {
            var result = await GetResponseAsync <TSource>(uri);

            return(AutoMapperService.Map <TSource, TDestination>(result));
        }
Beispiel #3
0
        protected async Task <TDestination> GetResponseAsync <TSource, TDestination>(RegionEnum?region,
                                                                                     string relativeUrl)
            where TSource : class
        {
            var result = await GetResponseAsync <TSource>(BuildUri(region, relativeUrl));

            return(AutoMapperService.Map <TSource, TDestination>(result));
        }
Beispiel #4
0
 protected virtual void Dispose(bool canCleanUpManagedandNativeRessources)
 {
     if (canCleanUpManagedandNativeRessources)
     {
         if (AutoMapperService != null)
         {
             AutoMapperService.Dispose();
             AutoMapperService = null;
         }
     }
 }