Example #1
0
 /// <summary>
 /// Used internally only for unit testing.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">A mapping of HttpStatusCode to expiration times. If unspecified takes a default value.</param>
 /// <param name="cache">The distributed cache to use.</param>
 /// /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 internal RedisCacheHandler(HttpMessageHandler innerHandler, IDictionary <HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode, IDistributedCache cache,
                            IStatsProvider statsProvider = null) : base(innerHandler ?? new HttpClientHandler())
 {
     this.StatsProvider = statsProvider ?? new StatsProvider(nameof(RedisCacheHandler));
     this.cacheExpirationPerHttpResponseCode = cacheExpirationPerHttpResponseCode ?? new Dictionary <HttpStatusCode, TimeSpan>();
     responseCache = cache;
 }
Example #2
0
 public ContentManager(IWarmingRepository warmingRepository, IOenRepository oenRepository, IRedirectLinkService redirectLinkService, IStatsProvider statsProvider)
 {
     _warmingRepository = warmingRepository;
     _oenRepository = oenRepository;
     _redirectLinkService = redirectLinkService;
     _statsProvider = statsProvider;
 }
 /// <summary>
 ///     Used for injecting an IMemoryCache for unit testing purposes.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">
 ///     A mapping of HttpStatusCode to expiration times. If unspecified takes
 ///     a default value.
 /// </param>
 /// <param name="statsProvider">
 ///     An <see cref="IStatsProvider" /> that records statistic information about the caching
 ///     behavior.
 /// </param>
 /// <param name="cache">The cache to be used.</param>
 internal InMemoryCacheHandler(HttpMessageHandler innerHandler, IDictionary <HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode, IStatsProvider statsProvider, IMemoryCache cache)
     : base(innerHandler ?? new HttpClientHandler())
 {
     this.StatsProvider = statsProvider ?? new StatsProvider(nameof(InMemoryCacheHandler));
     this.cacheExpirationPerHttpResponseCode = cacheExpirationPerHttpResponseCode ?? new Dictionary <HttpStatusCode, TimeSpan>();
     this.responseCache = cache ?? new MemoryCache(new MemoryCacheOptions());
 }
 /// <summary>
 /// Used for injecting an IMemoryCache for unit testing purposes.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="maxTimeout">The maximum timeout to wait for the service to respond.</param>
 /// <param name="cacheDuration">The maximum time span the item should be remained in the cache if not renewed before then.</param>
 /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 /// <param name="cache">The cache to be used.</param>
 internal InMemoryCacheFallbackHandler(HttpMessageHandler innerHandler, TimeSpan maxTimeout, TimeSpan cacheDuration, IStatsProvider statsProvider, IMemoryCache cache) : base(innerHandler ?? new HttpClientHandler())
 {
     this.StatsProvider = statsProvider ?? new StatsProvider(nameof(InMemoryCacheHandler));
     this.maxTimeout    = maxTimeout;
     this.cacheDuration = cacheDuration;
     responseCache      = cache ?? new MemoryCache(new MemoryCacheOptions());
 }
Example #5
0
        public static void Add(IStatsProvider statsProvider, ComplexGraphType <object> type)
        {
            type.Field <ListGraphType <StatType> >("stats", arguments: new QueryArguments
            {
                new QueryArgument(typeof(StringGraphType))
                {
                    Name        = "team1",
                    Description = "Team 1"
                },

                new QueryArgument(typeof(StringGraphType))
                {
                    Name        = "team2",
                    Description = "Team 2"
                }
            },
                                                   resolve: context =>
            {
                var c     = context as ResolveFieldContext;
                var team1 = c.Arguments["team1"].ToString();
                var team2 = c.Arguments["team2"].ToString();

                return(statsProvider.GetStatsAsync(team1, team2).Result);
            });
        }
 /// <summary>
 /// Used internally only for unit testing.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">A mapping of HttpStatusCode to expiration times. If unspecified takes a default value.</param>
 /// <param name="cache">The distributed cache to use.</param>
 /// /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 internal RedisCacheHandler(HttpMessageHandler innerHandler, IDictionary<HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode, IDistributedCache cache,
     IStatsProvider statsProvider = null) : base(innerHandler ?? new HttpClientHandler())
 {
     this.StatsProvider = statsProvider ?? new StatsProvider(nameof(RedisCacheHandler));
     this.cacheExpirationPerHttpResponseCode = cacheExpirationPerHttpResponseCode ?? new Dictionary<HttpStatusCode, TimeSpan>();
     responseCache = cache;
 }
 /// <summary>
 /// Used internally only for unit testing.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="maxTimeout">The maximum timeout to wait for the service to respond.</param>
 /// <param name="cacheDuration">The maximum time span the item should be remained in the cache if not renewed before then.</param>
 /// <param name="cache">The distributed cache to use.</param>
 /// /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 internal RedisCacheFallbackHandler(HttpMessageHandler innerHandler, TimeSpan maxTimeout, TimeSpan cacheDuration, IDistributedCache cache,
                                    IStatsProvider statsProvider = null) : base(innerHandler ?? new HttpClientHandler())
 {
     this.StatsProvider = statsProvider ?? new StatsProvider(nameof(RedisCacheHandler));
     this.maxTimeout    = maxTimeout;
     this.cacheDuration = cacheDuration;
     responseCache      = cache;
 }
Example #8
0
 public ApplicationModel()
 {
     #if DEBUG
     Stats = new Data.Debug.DebugStatsProvider();
     #else
     Stats = new VkStatsProvider();
     #endif
     MapView    = new MapView(new IpApiGeoLocationProvider());
     Photos     = new PhotoCollection(new VkPhotoProvider());
     LocalFiles = new LocalFileCollection();
     Users      = new Users(new VkUserProvider());
 }
Example #9
0
        public FplStats(IStatsProvider statsProvider, IFplDataManager fplDataManager, IModelCalculator modelCalculator, ISettingDataManager settingDataManager)
        {
            _statsProvider   = statsProvider;
            _fplDataManager  = fplDataManager;
            _modelCalculator = modelCalculator;

            var result = settingDataManager.GetAllSettings();

            if (!result.Status)
            {
                throw new Exception();
            }

            Utility.SetAllSettings(result.DataObject);
        }
        public void Register(IStatsProvider provider)
        {
            foreach (var stat in provider.Stats)
            {
                if (stat == null || string.IsNullOrEmpty(stat.Key))
                {
                    Core.Support.LogError(this, "trying to register an invalid stat (null or empty key)");
                    continue;
                }

                IStat existedStat;
                if (_stats.TryGetValue(stat.Key, out existedStat))
                {
                    Core.Support.LogError(this,
                                          string.Format(
                                              "a stat with the key '{0}' (name='{1}') is already existed. it will be replaced with the new one (name='{2}')",
                                              stat.Key,
                                              stat.Name,
                                              existedStat.Name));
                }

                _stats[stat.Key] = stat;
            }
        }
Example #11
0
        public WarmingManager
        (
           IWarmingWordsProvider wordsProvider,
           IWarmingService warmingService,
           IUsedWordsRepository usedWordsRepository,
           IWarmingRepository warmingRepository,
           IOenRepository oenRepository,
           IHeatRepository heatRepository,
           IContentManager contentManager,
            IStatsProvider statsProvider)
        {
            _wordsProvider = wordsProvider;

            _warmingService = warmingService;
            _warmingService.OnReport += NotificationReport;
            _warmingService.OnError += NotificationError;

            _usedWordsRepository = usedWordsRepository;
            _warmingRepository = warmingRepository;
            _oenRepository = oenRepository;
            _heatRepository = heatRepository;
            _contentManager = contentManager;
            _statsProvider = statsProvider;
        }
Example #12
0
 /// <summary>
 /// Used for injecting an IMemoryCache for unit testing purposes.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">A mapping of HttpStatusCode to expiration times. If unspecified takes a default value.</param>
 /// <param name="options">Options to use to connect to Redis.</param>
 /// /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 public RedisCacheHandler(HttpMessageHandler innerHandler, IDictionary <HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode, RedisCacheOptions options,
                          IStatsProvider statsProvider = null) : this(innerHandler, cacheExpirationPerHttpResponseCode, new RedisCache(options), statsProvider)
 {
 }
Example #13
0
 public WarmingService(OenContext context, IOenRepository oenRepository, IStatsProvider statsProvider)
 {
     _context = context;
     _oenRepository = oenRepository;
     _statsProvider = statsProvider;
 }
Example #14
0
 public SpecializationStats(IStatsProvider wrappedEntity, PlayerSpecialization specialization) : base(wrappedEntity)
 {
     this.specialization = specialization;
 }
Example #15
0
 public StatsController(IStatsProvider statsProvider)
 {
     _statsProvider = statsProvider;
 }
 /// <summary>
 /// Create a new InMemoryCacheHandler.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="maxTimeout">The maximum timeout to wait for the service to respond.</param>
 /// <param name="cacheDuration">The maximum time span the item should be remained in the cache if not renewed before then.</param>
 /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 public InMemoryCacheFallbackHandler(HttpMessageHandler innerHandler, TimeSpan maxTimeout, TimeSpan cacheDuration, IStatsProvider statsProvider = null)
     : this(innerHandler, maxTimeout, cacheDuration, statsProvider, new MemoryCache(new MemoryCacheOptions()))
 {
 }
 /// <summary>
 /// Used for injecting an IMemoryCache for unit testing purposes.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">A mapping of HttpStatusCode to expiration times. If unspecified takes a default value.</param>
 /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 /// <param name="cache">The cache to be used.</param>
 internal InMemoryCacheHandler(HttpMessageHandler innerHandler, IDictionary<HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode, IStatsProvider statsProvider, IMemoryCache cache) : base(innerHandler ?? new HttpClientHandler())
 {
     this.StatsProvider = statsProvider ?? new StatsProvider(nameof(InMemoryCacheHandler));
     this.cacheExpirationPerHttpResponseCode = cacheExpirationPerHttpResponseCode ?? new Dictionary<HttpStatusCode, TimeSpan>();
     responseCache = cache ?? new MemoryCache(new MemoryCacheOptions());
 }
 /// <summary>
 /// Create a new InMemoryCacheHandler.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">A mapping of HttpStatusCode to expiration times. If unspecified takes a default value.</param>
 /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 public InMemoryCacheHandler(HttpMessageHandler innerHandler, IDictionary<HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode = null, IStatsProvider statsProvider = null)
     : this(innerHandler, cacheExpirationPerHttpResponseCode, statsProvider, new MemoryCache(new MemoryCacheOptions())) {}
 public SoccerQuery(ITeamsProvider teamsProvider, IStatsProvider statsProvider)
 {
     Teams.Add(teamsProvider, this);
     Stats.Add(statsProvider, this);
     WinnigStats.Add(statsProvider, this);
 }
Example #20
0
 public Player()
 {
     provider = new CategoryStats(category);
     provider = new SpecializationStats(provider, specialization);
     provider = new MultiplierStats(provider, 2);
 }
 public void AddStatsProvider(IStatsProvider statsProvider)
 {
     statsProviders.Add(statsProvider);
 }
 /// <summary>
 /// Used for injecting an IMemoryCache for unit testing purposes.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="maxTimeout">The maximum timeout to wait for the service to respond.</param>
 /// <param name="cacheDuration">The maximum time span the item should be remained in the cache if not renewed before then.</param>
 /// <param name="options">Options to use to connect to Redis.</param>
 /// /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 public RedisCacheFallbackHandler(HttpMessageHandler innerHandler, TimeSpan maxTimeout, TimeSpan cacheDuration, RedisCacheOptions options,
                                  IStatsProvider statsProvider = null) : this(innerHandler, maxTimeout, cacheDuration, new RedisCache(options), statsProvider)
 {
 }
 /// <summary>
 /// Used for injecting an IMemoryCache for unit testing purposes.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">A mapping of HttpStatusCode to expiration times. If unspecified takes a default value.</param>
 /// <param name="options">Options to use to connect to Redis.</param>
 /// /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 public RedisCacheHandler(HttpMessageHandler innerHandler, IDictionary<HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode, RedisCacheOptions options,
     IStatsProvider statsProvider = null) : this(innerHandler, cacheExpirationPerHttpResponseCode, new RedisCache(options), statsProvider) {}
Example #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseRowProcessor"/> class.
 /// </summary>
 /// <param name="statsProvider">Statistical provider to generate key.</param>
 /// <param name="logger">A <see cref="ILogger"/> instance.</param>
 protected BaseRowProcessor(IStatsProvider statsProvider, ILogger logger)
 {
     _statsProvider = statsProvider;
     _logger        = logger;
 }
 /// <summary>
 ///     Create a new InMemoryCacheHandler.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">
 ///     A mapping of HttpStatusCode to expiration times. If unspecified takes
 ///     a default value.
 /// </param>
 /// <param name="statsProvider">
 ///     An <see cref="IStatsProvider" /> that records statistic information about the caching
 ///     behavior.
 /// </param>
 public InMemoryCacheHandler(HttpMessageHandler innerHandler = null, IDictionary <HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode = null, IStatsProvider statsProvider = null)
     : this(innerHandler, cacheExpirationPerHttpResponseCode, statsProvider, new MemoryCache(new MemoryCacheOptions()))
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="JHopkinsRowProcessor"/> class.
 /// </summary>
 /// <param name="namesService">Names service to translate name and abbreviations.</param>
 /// <param name="statsProvider">Statistical provider to generate key.</param>
 /// <param name="logger">A <see cref="ILogger"/> instance.</param>
 public JHopkinsRowProcessor(INames namesService, IStatsProvider statsProvider, ILogger logger) : base(statsProvider, logger)
 {
     _namesService = namesService;
 }
 protected StatsDecorator(IStatsProvider wrappedEntity)
 {
     this.wrappedEntity = wrappedEntity;
 }
Example #28
0
 public MultiplierStats(IStatsProvider wrappedEntity, float multiplier) : base(wrappedEntity)
 {
     this.multiplier = multiplier;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="YandexRussiaRowProcessor"/> class.
 /// </summary>
 /// <param name="statsProvider">Statistical provider to generate key.</param>
 /// <param name="logger">A <see cref="ILogger"/> instance.</param>
 public YandexRussiaRowProcessor(IStatsProvider statsProvider, ILogger logger) : base(statsProvider, logger)
 {
 }
Example #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StatsService"/> class.
 /// </summary>
 /// <param name="provider">The stats-related data provider..</param>
 /// <param name="environmentalDataRepository">The environmental data repository.</param>
 public StatsService(IStatsProvider provider, IEnvironmentalDataRepository environmentalDataRepository)
 {
     Provider = provider;
     EnvironmentalDataRepository = environmentalDataRepository;
 }