예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportableCI"/> class
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableCI"/> containing information about the sport entity</param>
        internal SportEntityCI(ExportableCI exportable)
        {
            if (exportable == null)
            {
                throw new ArgumentNullException(nameof(exportable));
            }

            Id = URN.Parse(exportable.Id);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheItem"/> class.
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableCI"/> representing the cache item</param>
        public CacheItem(ExportableCI exportable)
        {
            if (exportable == null)
            {
                throw new ArgumentNullException(nameof(exportable));
            }

            Id   = URN.Parse(exportable.Id);
            Name = new Dictionary <CultureInfo, string>(exportable.Name);
        }
예제 #3
0
        /// <summary>
        /// Builds a <see cref="SportEventCI"/> instance from the provided exportable cache item
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableCI"/> representing the sport event</param>
        /// <returns>a new instance of <see cref="SportEventCI"/> instance</returns>
        public SportEventCI Build(ExportableCI exportable)
        {
            if (exportable == null)
            {
                throw new ArgumentNullException(nameof(exportable));
            }
            var exportableSportEvent = exportable as ExportableSportEventCI;

            if (exportableSportEvent == null)
            {
                throw new ArgumentOutOfRangeException(nameof(exportableSportEvent), "The exportable must be a subclass of ExportableSportEventCI");
            }

            var eventId = URN.Parse(exportable.Id);

            if (eventId.TypeGroup == ResourceTypeGroup.STAGE)
            {
                return(new StageCI(exportableSportEvent as ExportableStageCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }
            if (eventId.TypeGroup == ResourceTypeGroup.MATCH)
            {
                return(new MatchCI(exportableSportEvent as ExportableMatchCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }
            if (eventId.TypeGroup == ResourceTypeGroup.SEASON ||
                eventId.TypeGroup == ResourceTypeGroup.BASIC_TOURNAMENT ||
                eventId.TypeGroup == ResourceTypeGroup.TOURNAMENT)
            {
                return(new TournamentInfoCI(exportableSportEvent as ExportableTournamentInfoCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }
            if (eventId.TypeGroup == ResourceTypeGroup.DRAW)
            {
                return(new DrawCI(exportableSportEvent as ExportableDrawCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }
            if (eventId.TypeGroup == ResourceTypeGroup.LOTTERY)
            {
                return(new LotteryCI(exportableSportEvent as ExportableLotteryCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }
            return(new SportEventCI(exportableSportEvent, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
        }
예제 #4
0
        /// <summary>
        /// Builds a <see cref="SportEventCI"/> instance from the provided exportable cache item
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableCI"/> representing the sport event</param>
        /// <returns>a new instance of <see cref="SportEventCI"/> instance</returns>
        public SportEventCI Build(ExportableCI exportable)
        {
            var exportableSportEvent = exportable as ExportableSportEventCI;

            if (exportableSportEvent == null)
            {
                return(null);
            }

            if (exportable is ExportableStageCI extStageCI)
            {
                return(new StageCI(extStageCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }

            if (exportable is ExportableMatchCI extMatchCI)
            {
                return(new MatchCI(extMatchCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }

            if (exportable is ExportableTournamentInfoCI extTournamentInfoCI)
            {
                return(new TournamentInfoCI(extTournamentInfoCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }

            if (exportable is ExportableLotteryCI extLotteryCI)
            {
                return(new LotteryCI(extLotteryCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }

            if (exportable is ExportableDrawCI extDrawCI)
            {
                return(new DrawCI(extDrawCI, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
            }

            return(new SportEventCI(exportableSportEvent, _dataRouterManager, _semaphorePool, _defaultCulture, _fixtureTimestampCache));
        }