Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportDataProvider"/> class
        /// </summary>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to construct <see cref="ITournament"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to retrieve schedules for sport events</param>
        /// <param name="sportEventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve status for sport event</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> ued to retrieve competitor or player profile</param>
        /// <param name="defaultCultures"> A <see cref="IList{CultureInfo}"/> specified as default cultures (from configuration)</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying enum member specifying how instances provided by the current provider will handle exceptions</param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        public SportDataProvider(ISportEntityFactory sportEntityFactory,
                                 ISportEventCache sportEventCache,
                                 ISportEventStatusCache sportEventStatusCache,
                                 IProfileCache profileCache,
                                 IEnumerable <CultureInfo> defaultCultures,
                                 ExceptionHandlingStrategy exceptionStrategy,
                                 ICacheManager cacheManager,
                                 ILocalizedNamedValueCache matchStatusCache,
                                 IDataRouterManager dataRouterManager)
        {
            Contract.Requires(sportEntityFactory != null);
            Contract.Requires(sportEventCache != null);
            Contract.Requires(profileCache != null);
            Contract.Requires(defaultCultures != null);
            Contract.Requires(defaultCultures.Any());
            Contract.Requires(cacheManager != null);
            Contract.Requires(matchStatusCache != null);
            Contract.Requires(dataRouterManager != null);

            _sportEntityFactory    = sportEntityFactory;
            _sportEventCache       = sportEventCache;
            _sportEventStatusCache = sportEventStatusCache;
            _profileCache          = profileCache;
            _defaultCultures       = defaultCultures as IReadOnlyCollection <CultureInfo>;
            _exceptionStrategy     = exceptionStrategy;
            _cacheManager          = cacheManager;
            _matchStatusCache      = matchStatusCache;
            _dataRouterManager     = dataRouterManager;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportDataProvider"/> class
        /// </summary>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to construct <see cref="ITournament"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to retrieve schedules for sport events</param>
        /// <param name="sportEventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve status for sport event</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve competitor or player profile</param>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> used to retrieve sport data</param>
        /// <param name="defaultCultures"> A <see cref="IList{CultureInfo}"/> specified as default cultures (from configuration)</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying enum member specifying how instances provided by the current provider will handle exceptions</param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="dataRouterManager">A <see cref="IDataRouterManager"/> used to invoke API requests</param>
        public SportDataProvider(ISportEntityFactory sportEntityFactory,
                                 ISportEventCache sportEventCache,
                                 ISportEventStatusCache sportEventStatusCache,
                                 IProfileCache profileCache,
                                 ISportDataCache sportDataCache,
                                 IEnumerable <CultureInfo> defaultCultures,
                                 ExceptionHandlingStrategy exceptionStrategy,
                                 ICacheManager cacheManager,
                                 ILocalizedNamedValueCache matchStatusCache,
                                 IDataRouterManager dataRouterManager)
        {
            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(defaultCultures, nameof(defaultCultures)).NotNull().NotEmpty();
            Guard.Argument(cacheManager, nameof(cacheManager)).NotNull();
            Guard.Argument(matchStatusCache, nameof(matchStatusCache)).NotNull();
            Guard.Argument(dataRouterManager, nameof(dataRouterManager)).NotNull();

            _sportEntityFactory    = sportEntityFactory;
            _sportEventCache       = sportEventCache;
            _sportEventStatusCache = sportEventStatusCache;
            _profileCache          = profileCache;
            _sportDataCache        = sportDataCache;
            _defaultCultures       = defaultCultures as IReadOnlyCollection <CultureInfo>;
            _exceptionStrategy     = exceptionStrategy;
            _cacheManager          = cacheManager;
            _matchStatusCache      = matchStatusCache;
            _dataRouterManager     = dataRouterManager;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportDataCache"/> class
        /// </summary>
        /// <param name="dataRouterManager">A <see cref="IDataRouterManager"/> used to fetch all required data</param>
        /// <param name="timer">A <see cref="ITimer"/> instance used to periodically fetch sport related data</param>
        /// <param name="cultures">A list of <see cref="CultureInfo"/> of the cached data</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> containing also tournament data</param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        public SportDataCache(IDataRouterManager dataRouterManager,
                              ITimer timer,
                              IEnumerable <CultureInfo> cultures,
                              ISportEventCache sportEventCache,
                              ICacheManager cacheManager)
            : base(cacheManager)
        {
            Contract.Requires(dataRouterManager != null);
            Contract.Requires(timer != null);
            Contract.Requires(cultures != null && cultures.Any());
            Contract.Requires(sportEventCache != null);

            _dataRouterManager = dataRouterManager;
            _requiredCultures  = cultures as ReadOnlyCollection <CultureInfo> ?? new ReadOnlyCollection <CultureInfo>(cultures.ToList());

            FetchedCultures  = new HashSet <CultureInfo>();
            Sports           = new ConcurrentDictionary <URN, SportCI>();
            Categories       = new ConcurrentDictionary <URN, CategoryCI>();
            _sportEventCache = sportEventCache;

            _isDisposed = false;

            _timer          = timer;
            _timer.Elapsed += OnTimerElapsed;
            _timer.Start();
        }
        private readonly ConcurrentDictionary <EventChangeEventArgs, bool> _eventUpdates; // boolean value indicating if this is fixture update

        public EventChangeManager(TimeSpan fixtureChangeInterval,
                                  TimeSpan resultChangeInterval,
                                  ISportDataProvider sportDataProvider,
                                  ISportEventCache sportEventCache,
                                  IOddsFeedConfiguration config,
                                  IMetricsRoot metricsRoot)
        {
            Guard.Argument(config, nameof(config)).NotNull();
            Guard.Argument(sportDataProvider, nameof(sportDataProvider)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();

            _config            = config;
            _sportDataProvider = (SportDataProvider)sportDataProvider;
            _sportEventCache   = sportEventCache;
            _metricsRoot       = metricsRoot;

            LastFixtureChange     = DateTime.MinValue;
            LastResultChange      = DateTime.MinValue;
            FixtureChangeInterval = fixtureChangeInterval >= TimeSpan.FromMinutes(1) ? fixtureChangeInterval : TimeSpan.FromHours(1);
            ResultChangeInterval  = resultChangeInterval >= TimeSpan.FromMinutes(1) ? resultChangeInterval : TimeSpan.FromHours(1);
            IsRunning             = false;

            _fixtureTimer          = new SdkTimer(TimeSpan.FromSeconds(1), fixtureChangeInterval);
            _resultTimer           = new SdkTimer(TimeSpan.FromSeconds(1), ResultChangeInterval);
            _fixtureTimer.Elapsed += FixtureTimerOnElapsed;
            _resultTimer.Elapsed  += ResultTimerOnElapsed;

            _eventUpdates = new ConcurrentDictionary <EventChangeEventArgs, bool>();

            _isDispatching = false;
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Draw"/> class
 /// </summary>
 /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event associated with the current instance</param>
 /// <param name="sportId">A <see cref="URN"/> uniquely identifying the sport associated with the current instance</param>
 /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the initialized instance will handle potential exceptions</param>
 public Draw(URN id,
             URN sportId,
             ISportEventCache sportEventCache,
             IEnumerable <CultureInfo> cultures,
             ExceptionHandlingStrategy exceptionStrategy)
     : base(id, sportId, ExecutionLogPrivate, sportEventCache, cultures, exceptionStrategy)
 {
 }
Пример #6
0
        public void Init()
        {
            _cacheManager      = new CacheManager();
            _dataRouterManager = new TestDataRouterManager(_cacheManager);

            _memoryCache = new MemoryCache("cache");

            _timer           = new TestTimer(false);
            _sportEventCache = new SportEventCache(_memoryCache, _dataRouterManager, new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5, ExceptionHandlingStrategy.THROW), _cultureEn, new MemoryCache("FixtureTimestampCache")), _timer, TestData.Cultures, _cacheManager);
            _sportDataCache  = new SportDataCache(_dataRouterManager, _timer, TestData.Cultures, _sportEventCache, _cacheManager);
        }
Пример #7
0
 public SoccerEvent(URN id,
                    URN sportId,
                    ISportEntityFactory sportEntityFactory,
                    ISportEventCache sportEventCache,
                    ISportEventStatusCache sportEventStatusCache,
                    ILocalizedNamedValueCache matchStatusCache,
                    IEnumerable <CultureInfo> cultures,
                    ExceptionHandlingStrategy exceptionStrategy)
     : base(id, sportId, sportEntityFactory, sportEventCache, sportEventStatusCache, matchStatusCache, cultures, exceptionStrategy)
 {
 }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Draw"/> class
        /// </summary>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event associated with the current instance</param>
        /// <param name="sportId">A <see cref="URN"/> uniquely identifying the sport associated with the current instance</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve basic tournament information</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the initialized instance will handle potential exceptions</param>
        public Lottery(URN id,
                       URN sportId,
                       ISportEventCache sportEventCache,
                       ISportDataCache sportDataCache,
                       IEnumerable <CultureInfo> cultures,
                       ExceptionHandlingStrategy exceptionStrategy)
            : base(id, sportId, ExecutionLogPrivate, sportEventCache, cultures, exceptionStrategy)
        {
            Guard.Argument(sportDataCache, nameof(sportDataCache)).NotNull();

            _sportDataCache = sportDataCache;
        }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Match"/> class.
 /// </summary>
 /// <param name="id">A <see cref="URN"/> uniquely identifying the match associated with the current instance</param>
 /// <param name="sportId">A <see cref="URN"/> uniquely identifying the sport associated with the current instance</param>
 /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> instance used to construct <see cref="ITournament"/> instances</param>
 /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instances containing cache data associated with the current instance</param>
 /// <param name="sportEventStatusCache">A <see cref="ISportEventStatusCache"/> instance containing cache data information about the progress of a match associated with the current instance</param>
 /// <param name="matchStatusCache">A localized match statuses cache</param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the initialized instance will handle potential exceptions</param>
 public Match(URN id,
             URN sportId,
             ISportEntityFactory sportEntityFactory,
             ISportEventCache sportEventCache,
             ISportEventStatusCache sportEventStatusCache,
             ILocalizedNamedValueCache matchStatusCache,
             IEnumerable<CultureInfo> cultures,
             ExceptionHandlingStrategy exceptionStrategy)
     : base(ExecutionLogPrivate, id, sportId, sportEntityFactory, sportEventStatusCache, sportEventCache, cultures, exceptionStrategy, matchStatusCache)
 {
     _sportEntityFactory = sportEntityFactory;
 }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Draw"/> class
        /// </summary>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event associated with the current instance</param>
        /// <param name="sportId">A <see cref="URN"/> uniquely identifying the sport associated with the current instance</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve basic tournament information</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the initialized instance will handle potential exceptions</param>
        public Lottery(URN id,
                       URN sportId,
                       ISportEventCache sportEventCache,
                       ISportDataCache sportDataCache,
                       IEnumerable <CultureInfo> cultures,
                       ExceptionHandlingStrategy exceptionStrategy)
            : base(id, sportId, ExecutionLogPrivate, sportEventCache, cultures, exceptionStrategy)
        {
            Contract.Requires(sportDataCache != null);

            _sportDataCache = sportDataCache;
        }
Пример #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicTournament"/> class
        /// </summary>
        /// <param name="id">The identifier</param>
        /// <param name="sportId">The sport identifier</param>
        /// <param name="sportEntityFactory">An instance of a <see cref="ISportEntityFactory"/> used to create <see cref="ISportEvent"/> instances</param>
        /// <param name="sportEventCache">The sport event cache</param>
        /// <param name="sportDataCache">The sport data cache</param>
        /// <param name="cultures">The cultures</param>
        /// <param name="exceptionStrategy">The exception strategy</param>
        public BasicTournament(URN id,
                               URN sportId,
                               ISportEntityFactory sportEntityFactory,
                               ISportEventCache sportEventCache,
                               ISportDataCache sportDataCache,
                               IEnumerable <CultureInfo> cultures,
                               ExceptionHandlingStrategy exceptionStrategy)
            : base(id, sportId, ExecutionLogPrivate, sportEventCache, cultures, exceptionStrategy)
        {
            Guard.Argument(sportDataCache, nameof(sportDataCache)).NotNull();
            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();

            _sportEntityFactory = sportEntityFactory;
            _sportDataCache     = sportDataCache;
        }
Пример #12
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BasicTournament" /> class
        /// </summary>
        /// <param name="id">The identifier</param>
        /// <param name="sportId">The sport identifier</param>
        /// <param name="sportEntityFactory">
        ///     An instance of a <see cref="ISportEntityFactory" /> used to create
        ///     <see cref="ISportEvent" /> instances
        /// </param>
        /// <param name="sportEventCache">The sport event cache</param>
        /// <param name="sportDataCache">The sport data cache</param>
        /// <param name="cultures">The cultures</param>
        /// <param name="exceptionStrategy">The exception strategy</param>
        public BasicTournament(URN id,
                               URN sportId,
                               ISportEntityFactory sportEntityFactory,
                               ISportEventCache sportEventCache,
                               ISportDataCache sportDataCache,
                               IEnumerable <CultureInfo> cultures,
                               ExceptionHandlingStrategy exceptionStrategy)
            : base(id, sportId, ExecutionLogPrivate, sportEventCache, cultures, exceptionStrategy)
        {
            Contract.Requires(sportDataCache != null);
            Contract.Requires(sportEntityFactory != null);

            _sportEntityFactory = sportEntityFactory;
            _sportDataCache     = sportDataCache;
        }
Пример #13
0
        public Stage(URN id,
                     URN sportId,
                     ISportEntityFactory sportEntityFactory,
                     ISportEventCache sportEventCache,
                     ISportDataCache sportDataCache,
                     ISportEventStatusCache sportEventStatusCache,
                     ILocalizedNamedValueCache matchStatusesCache,
                     IEnumerable <CultureInfo> cultures,
                     ExceptionHandlingStrategy exceptionStrategy)
            : base(ExecutionLogPrivate, id, sportId, sportEntityFactory, sportEventStatusCache, sportEventCache, cultures, exceptionStrategy, matchStatusesCache)
        {
            Guard.Argument(sportDataCache, nameof(sportDataCache)).NotNull();
            Guard.Argument(matchStatusesCache, nameof(matchStatusesCache)).NotNull();

            _sportEntityFactory = sportEntityFactory;
            _sportDataCache     = sportDataCache;
        }
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheMessageProcessor"/> class
        /// </summary>
        /// <param name="mapperFactory">A <see cref="ISingleTypeMapperFactory{removeSportEventStatus, SportEventStatusDTO}"/> used to created <see cref="ISingleTypeMapper{SportEventStatusDTO}"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to handle <see cref="fixture_change"/></param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="feedMessageHandler">A <see cref="IFeedMessageHandler"/> for handling special cases</param>
        public CacheMessageProcessor(ISingleTypeMapperFactory <sportEventStatus, SportEventStatusDTO> mapperFactory,
                                     ISportEventCache sportEventCache,
                                     ICacheManager cacheManager,
                                     IFeedMessageHandler feedMessageHandler)
        {
            Guard.Argument(mapperFactory, nameof(mapperFactory)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(cacheManager, nameof(cacheManager)).NotNull();
            Guard.Argument(feedMessageHandler, nameof(feedMessageHandler)).NotNull();

            ProcessorId = "CMP" + Guid.NewGuid().ToString().Substring(0, 4);

            _mapperFactory      = mapperFactory;
            _sportEventCache    = sportEventCache;
            _cacheManager       = cacheManager;
            _feedMessageHandler = feedMessageHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheMessageProcessor"/> class
        /// </summary>
        /// <param name="mapperFactory">A <see cref="ISingleTypeMapperFactory{removeSportEventStatus, SportEventStatusDTO}"/> used to created <see cref="ISingleTypeMapper{SportEventStatusDTO}"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to handle <see cref="fixture_change"/></param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="feedMessageHandler">A <see cref="IFeedMessageHandler"/> for handling special cases</param>
        public CacheMessageProcessor(ISingleTypeMapperFactory <sportEventStatus, SportEventStatusDTO> mapperFactory,
                                     ISportEventCache sportEventCache,
                                     ICacheManager cacheManager,
                                     IFeedMessageHandler feedMessageHandler)
        {
            Contract.Requires(mapperFactory != null);
            Contract.Requires(sportEventCache != null);
            Contract.Requires(cacheManager != null);
            Contract.Requires(feedMessageHandler != null);

            ProcessorId = "CMP" + Guid.NewGuid().ToString().Substring(0, 4);

            _mapperFactory      = mapperFactory;
            _sportEventCache    = sportEventCache;
            _cacheManager       = cacheManager;
            _feedMessageHandler = feedMessageHandler;
        }
        public TestSportEntityFactory(ISportDataCache sportDataCache             = null,
                                      ISportEventCache sportEventCache           = null,
                                      ISportEventStatusCache eventStatusCache    = null,
                                      ILocalizedNamedValueCache matchStatusCache = null,
                                      IProfileCache profileCache = null,
                                      IReadOnlyCollection <URN> soccerSportUrns = null)
        {
            _cacheManager = new CacheManager();
            var profileMemoryCache = new MemoryCache("ProfileCache");

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache ?? new ProfileCache(profileMemoryCache, new TestDataRouterManager(_cacheManager), _cacheManager);
            _soccerSportUrns  = soccerSportUrns ?? SdkInfo.SoccerSportUrns;
        }
Пример #17
0
        public Stage(URN id,
                     URN sportId,
                     ISportEntityFactory sportEntityFactory,
                     ISportEventCache sportEventCache,
                     ISportDataCache sportDataCache,
                     ISportEventStatusCache sportEventStatusCache,
                     ILocalizedNamedValueCache matchStatusesCache,
                     IEnumerable <CultureInfo> cultures,
                     ExceptionHandlingStrategy exceptionStrategy)
            : base(ExecutionLogPrivate, id, sportId, sportEntityFactory, sportEventStatusCache, sportEventCache, cultures, exceptionStrategy, matchStatusesCache)
        {
            Contract.Requires(sportDataCache != null);
            Contract.Requires(matchStatusesCache != null);

            _sportEntityFactory = sportEntityFactory;
            _sportDataCache     = sportDataCache;
            _matchStatusesCache = matchStatusesCache;
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEvent"/> class
        /// </summary>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event</param>
        /// <param name="sportId">A <see cref="URN"/> identifying the sport current instance belong to</param>
        /// <param name="executionLog">The <see cref="ILog"/> instance used for execution logging</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the instance will handle potential exceptions</param>
        public SportEvent(URN id,
                          URN sportId,
                          ILog executionLog,
                          ISportEventCache sportEventCache,
                          IEnumerable <CultureInfo> cultures,
                          ExceptionHandlingStrategy exceptionStrategy)
        {
            Guard.Argument(id, nameof(id)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();

            Id                = id;
            SportId           = sportId;
            ExecutionLog      = executionLog ?? SdkLoggerFactory.GetLoggerForExecution(typeof(SportEvent));
            ExceptionStrategy = exceptionStrategy;
            Cultures          = cultures;
            SportEventCache   = sportEventCache;
        }
Пример #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEvent"/> class
        /// </summary>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event</param>
        /// <param name="sportId">A <see cref="URN"/> identifying the sport current instance belong to</param>
        /// <param name="executionLog">The <see cref="ILog"/> instance used for execution logging</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the instance will handle potential exceptions</param>
        public SportEvent(URN id,
                          URN sportId,
                          ILog executionLog,
                          ISportEventCache sportEventCache,
                          IEnumerable <CultureInfo> cultures,
                          ExceptionHandlingStrategy exceptionStrategy)
        {
            Contract.Requires(id != null);
            Contract.Requires(sportEventCache != null);
            Contract.Requires(cultures != null && cultures.Any());

            Id                = id;
            SportId           = sportId;
            ExecutionLog      = executionLog ?? SdkLoggerFactory.GetLoggerForExecution(typeof(SportEvent));
            ExceptionStrategy = exceptionStrategy;
            Cultures          = cultures;
            SportEventCache   = sportEventCache;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ISportEventStatusCache"/> class
        /// </summary>
        /// <param name="sportEventStatusCache">A <see cref="MemoryCache"/> used to cache <see cref="SportEventStatusCI"/> instances</param>
        /// <param name="mapperFactory">A <see cref="ISingleTypeMapperFactory{TIn,TOut}"/> used to created <see cref="ISingleTypeMapper{SportEventStatusDTO}"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to cache <see cref="ISportEvent"/></param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="ignoreEventsTimelineCache">A <see cref="MemoryCache"/> used to cache event ids for which the SES from timeline endpoint should be ignored</param>
        public SportEventStatusCache(MemoryCache sportEventStatusCache,
                                     ISingleTypeMapperFactory <sportEventStatus, SportEventStatusDTO> mapperFactory,
                                     ISportEventCache sportEventCache,
                                     ICacheManager cacheManager,
                                     MemoryCache ignoreEventsTimelineCache)
            : base(cacheManager)
        {
            Guard.Argument(sportEventStatusCache, nameof(sportEventStatusCache)).NotNull();
            Guard.Argument(mapperFactory, nameof(mapperFactory)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(ignoreEventsTimelineCache, nameof(ignoreEventsTimelineCache)).NotNull();

            _sportEventStatusCache     = sportEventStatusCache;
            _mapperFactory             = mapperFactory;
            _sportEventCache           = sportEventCache;
            _ignoreEventsTimelineCache = ignoreEventsTimelineCache;

            _isDisposed = false;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEntityFactory"/> class
        /// </summary>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve sport related info</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance used to retrieve sport events</param>
        /// <param name="eventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve statuses of sport events</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve player profiles</param>
        public SportEntityFactory(
            ISportDataCache sportDataCache,
            ISportEventCache sportEventCache,
            ISportEventStatusCache eventStatusCache,
            ILocalizedNamedValueCache matchStatusCache,
            IProfileCache profileCache)
        {
            Guard.Argument(sportDataCache, nameof(sportDataCache)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(eventStatusCache, nameof(eventStatusCache)).NotNull();
            Guard.Argument(matchStatusCache, nameof(matchStatusCache)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache;
        }
Пример #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEntityFactory"/> class
        /// </summary>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve sport related info</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance used to retrieve sport events</param>
        /// <param name="eventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve statuses of sport events</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve player profiles</param>
        public SportEntityFactory(
            ISportDataCache sportDataCache,
            ISportEventCache sportEventCache,
            ISportEventStatusCache eventStatusCache,
            ILocalizedNamedValueCache matchStatusCache,
            IProfileCache profileCache)
        {
            Contract.Requires(sportDataCache != null);
            Contract.Requires(sportEventCache != null);
            Contract.Requires(eventStatusCache != null);
            Contract.Requires(matchStatusCache != null);
            Contract.Requires(profileCache != null);

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache;
        }
Пример #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Competition"/> class
        /// </summary>
        /// <param name="executionLog">A <see cref="ILogger"/> instance used for execution logging</param>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event associated with the current instance</param>
        /// <param name="sportId">A <see cref="URN"/> uniquely identifying the sport associated with the current instance</param>
        /// <param name="sportEntityFactory">An instance of a <see cref="ISportEntityFactory"/> used to create <see cref="ISportEvent"/> instances</param>
        /// <param name="sportEventStatusCache">A <see cref="ISportEventStatusCache"/> instance containing cache data information about the progress of a sport event associated with the current instance</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="CompetitionCI"/></param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the initialized instance will handle potential exceptions</param>
        /// <param name="matchStatusesCache">A <see cref="ILocalizedNamedValueCache"/> cache for fetching match statuses</param>
        internal Competition(ILogger executionLog,
                             URN id,
                             URN sportId,
                             ISportEntityFactory sportEntityFactory,
                             ISportEventStatusCache sportEventStatusCache,
                             ISportEventCache sportEventCache,
                             IEnumerable <CultureInfo> cultures,
                             ExceptionHandlingStrategy exceptionStrategy,
                             ILocalizedNamedValueCache matchStatusesCache)
            : base(id, sportId, executionLog, sportEventCache, cultures, exceptionStrategy)
        {
            Guard.Argument(id, nameof(id)).NotNull();
            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();
            Guard.Argument(sportEventStatusCache, nameof(sportEventStatusCache)).NotNull();
            Guard.Argument(matchStatusesCache, nameof(matchStatusesCache)).NotNull();

            _sportEntityFactory   = sportEntityFactory;
            SportEventStatusCache = sportEventStatusCache;
            _matchStatusesCache   = matchStatusesCache;
        }
Пример #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Competition"/> class
        /// </summary>
        /// <param name="executionLog">A <see cref="ILog"/> instance used for execution logging</param>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event associated with the current instance</param>
        /// <param name="sportId">A <see cref="URN"/> uniquely identifying the sport associated with the current instance</param>
        /// <param name="sportEntityFactory">An instance of a <see cref="ISportEntityFactory"/> used to create <see cref="ISportEvent"/> instances</param>
        /// <param name="sportEventStatusCache">A <see cref="ISportEventStatusCache"/> instance containing cache data information about the progress of a sport event associated with the current instance</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="CompetitionCI"/></param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the initialized instance will handle potential exceptions</param>
        /// <param name="matchStatusesCache">A <see cref="ILocalizedNamedValueCache"/> cache for fetching match statuses</param>
        internal Competition(ILog executionLog,
                             URN id,
                             URN sportId,
                             ISportEntityFactory sportEntityFactory,
                             ISportEventStatusCache sportEventStatusCache,
                             ISportEventCache sportEventCache,
                             IEnumerable <CultureInfo> cultures,
                             ExceptionHandlingStrategy exceptionStrategy,
                             ILocalizedNamedValueCache matchStatusesCache)
            : base(id, sportId, executionLog, sportEventCache, cultures, exceptionStrategy)
        {
            Contract.Requires(id != null);
            Contract.Requires(sportEntityFactory != null);
            Contract.Requires(sportEventStatusCache != null);
            Contract.Requires(matchStatusesCache != null);

            _sportEntityFactory   = sportEntityFactory;
            SportEventStatusCache = sportEventStatusCache;
            _matchStatusesCache   = matchStatusesCache;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ISportEventStatusCache"/> class
        /// </summary>
        /// <param name="sportEventStatusCache"> A <see cref="MemoryCache"/> used to cache <see cref="SportEventStatusCI"/> instances</param>
        /// <param name="mapperFactory">A <see cref="ISingleTypeMapperFactory{TIn,TOut}"/> used to created <see cref="ISingleTypeMapper{SportEventStatusDTO}"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to cache <see cref="ISportEvent"/></param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="cacheItemExpireTime">The time in which cache item expires</param>
        public SportEventStatusCache(MemoryCache sportEventStatusCache,
                                     ISingleTypeMapperFactory <sportEventStatus, SportEventStatusDTO> mapperFactory,
                                     ISportEventCache sportEventCache,
                                     ICacheManager cacheManager,
                                     TimeSpan cacheItemExpireTime)
            : base(cacheManager)
        {
            Guard.Argument(sportEventStatusCache, nameof(sportEventStatusCache)).NotNull();
            Guard.Argument(mapperFactory, nameof(mapperFactory)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();

            _sportEventStatusCache = sportEventStatusCache;
            _mapperFactory         = mapperFactory;
            _sportEventCache       = sportEventCache;

            _isDisposed          = false;
            _cacheItemExpireTime = cacheItemExpireTime <= TimeSpan.Zero
                                       ? TimeSpan.FromMinutes(5)
                                       : cacheItemExpireTime;
        }
Пример #26
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ISportEventStatusCache" /> class
        /// </summary>
        /// <param name="sportEventStatusCache">
        ///     A <see cref="MemoryCache" /> used to cache <see cref="SportEventStatusCI" />
        ///     instances
        /// </param>
        /// <param name="mapperFactory">
        ///     A <see cref="ISingleTypeMapperFactory{TIn,TOut}" /> used to created
        ///     <see cref="ISingleTypeMapper{SportEventStatusDTO}" /> instances
        /// </param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache" /> used to cache <see cref="ISportEvent" /></param>
        /// <param name="cacheManager">A <see cref="ICacheManager" /> used to interact among caches</param>
        /// <param name="cacheItemExpireTime">The time in which cache item expires</param>
        public SportEventStatusCache(MemoryCache sportEventStatusCache,
                                     ISingleTypeMapperFactory <sportEventStatus, SportEventStatusDTO> mapperFactory,
                                     ISportEventCache sportEventCache,
                                     ICacheManager cacheManager,
                                     TimeSpan cacheItemExpireTime)
            : base(cacheManager)
        {
            Contract.Requires(sportEventStatusCache != null);
            Contract.Requires(mapperFactory != null);
            Contract.Requires(sportEventCache != null);

            _sportEventStatusCache = sportEventStatusCache;
            _mapperFactory         = mapperFactory;
            _sportEventCache       = sportEventCache;

            _isDisposed          = false;
            _cacheItemExpireTime = cacheItemExpireTime <= TimeSpan.Zero
                ? TimeSpan.FromMinutes(5)
                : cacheItemExpireTime;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEntityFactory"/> class
        /// </summary>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve sport related info</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance used to retrieve sport events</param>
        /// <param name="eventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve statuses of sport events</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve player profiles</param>
        /// <param name="soccerSportUrns">A list of sport urns that have soccer matches</param>
        public SportEntityFactory(ISportDataCache sportDataCache,
                                  ISportEventCache sportEventCache,
                                  ISportEventStatusCache eventStatusCache,
                                  ILocalizedNamedValueCache matchStatusCache,
                                  IProfileCache profileCache,
                                  IReadOnlyCollection <URN> soccerSportUrns)
        {
            Guard.Argument(sportDataCache, nameof(sportDataCache)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(eventStatusCache, nameof(eventStatusCache)).NotNull();
            Guard.Argument(matchStatusCache, nameof(matchStatusCache)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(soccerSportUrns, nameof(soccerSportUrns)).NotNull();

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache;
            _soccerSportUrns  = soccerSportUrns;
        }