/// <summary>
 /// Initializes a new instance of the <see cref="TournamentInfoCI"/> class
 /// </summary>
 /// <param name="exportable">A <see cref="ExportableTournamentInfoCI" /> specifying the current instance</param>
 /// <param name="dataRouterManager">The <see cref="IDataRouterManager"/> used to obtain summary and fixture</param>
 /// <param name="semaphorePool">A <see cref="ISemaphorePool" /> instance used to obtain sync objects</param>
 /// <param name="defaultCulture">A <see cref="CultureInfo" /> specifying the language used when fetching info which is not translatable (e.g. Scheduled, ..)</param>
 /// <param name="fixtureTimestampCache">A <see cref="MemoryCache"/> used to cache the sport events fixture timestamps</param>
 public TournamentInfoCI(ExportableTournamentInfoCI exportable,
                         IDataRouterManager dataRouterManager,
                         ISemaphorePool semaphorePool,
                         CultureInfo defaultCulture,
                         MemoryCache fixtureTimestampCache)
     : base(exportable, dataRouterManager, semaphorePool, defaultCulture, fixtureTimestampCache)
 {
     _categoryId         = exportable.CategoryId == null ? null : URN.Parse(exportable.CategoryId);
     _tournamentCoverage = exportable.TournamentCoverage != null
         ? new TournamentCoverageCI(exportable.TournamentCoverage)
         : null;
     _competitors       = exportable.Competitors?.Select(c => new CompetitorCI(c, dataRouterManager)).ToList();
     _currentSeasonInfo = exportable.CurrentSeasonInfo != null
         ? new CurrentSeasonInfoCI(exportable.CurrentSeasonInfo, dataRouterManager)
         : null;
     _groups              = exportable.Groups?.Select(g => new GroupCI(g, dataRouterManager)).ToList();
     _scheduleUrns        = exportable.ScheduleUrns?.Select(URN.Parse).ToList();
     _round               = exportable.Round != null ? new RoundCI(exportable.Round) : null;
     _year                = exportable.Year;
     _tournamentInfoBasic = exportable.TournamentInfoBasic != null
         ? new TournamentInfoBasicCI(exportable.TournamentInfoBasic, dataRouterManager)
         : null;
     _referenceId    = exportable.ReferenceId != null ? new ReferenceIdCI(exportable.ReferenceId) : null;
     _seasonCoverage = exportable.SeasonCoverage != null
         ? new SeasonCoverageCI(exportable.SeasonCoverage)
         : null;
     _seasons               = exportable.Seasons?.Select(URN.Parse).ToList();
     _loadedSeasons         = new List <CultureInfo>(exportable.LoadedSeasons ?? new List <CultureInfo>());
     _loadedSchedules       = new List <CultureInfo>(exportable.LoadedSchedules ?? new List <CultureInfo>());
     _competitorsReferences =
         exportable.CompetitorsReferences?.ToDictionary(c => URN.Parse(c.Key), c => new ReferenceIdCI(c.Value));
     _exhibitionGames = exportable.ExhibitionGames;
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TournamentInfo" /> class.
 /// </summary>
 /// <param name="cacheItem">The cache item</param>
 /// <param name="categorySummary">The category summary</param>
 /// <param name="currentSeasonInfo">The full current season info</param>
 public TournamentInfo(TournamentInfoBasicCI cacheItem, ICategorySummary categorySummary,
                       ICurrentSeasonInfo currentSeasonInfo)
     : base(cacheItem.Id, cacheItem.Name as IReadOnlyDictionary <CultureInfo, string>)
 {
     Category      = categorySummary;
     CurrentSeason = currentSeasonInfo;
 }
        /// <summary>
        /// Merges the specified dto
        /// </summary>
        /// <param name="dto">The dto</param>
        /// <param name="culture">The culture</param>
        private void ActualMerge(TournamentInfoDTO dto, CultureInfo culture)
        {
            base.Merge(dto, culture, false);

            if (dto.Category != null)
            {
                _categoryId = dto.Category.Id;
            }
            if (dto.TournamentCoverage != null)
            {
                _tournamentCoverage = new TournamentCoverageCI(dto.TournamentCoverage);
            }
            if (dto.Competitors != null)
            {
                if (_competitors == null)
                {
                    _competitors = new List <CompetitorCI>(dto.Competitors.Select(t => new CompetitorCI(t, culture, DataRouterManager)));
                }
                else
                {
                    MergeCompetitors(dto.Competitors, culture);
                }
                FillCompetitorsReferences(dto.Competitors);
            }
            if (dto.CurrentSeason != null)
            {
                if (_currentSeasonInfo == null)
                {
                    _currentSeasonInfo = new CurrentSeasonInfoCI(dto.CurrentSeason, culture, DataRouterManager);
                }
                else
                {
                    _currentSeasonInfo.Merge(dto.CurrentSeason, culture);
                }
            }
            if (dto.Groups != null)
            {
                if (_groups == null)
                {
                    _groups = new List <GroupCI>(dto.Groups.Select(s => new GroupCI(s, culture, DataRouterManager)));
                }
                else
                {
                    MergeGroups(dto.Groups, culture);
                }
                var comps = new List <CompetitorDTO>();
                foreach (var groupDTO in dto.Groups)
                {
                    comps.AddRange(groupDTO.Competitors);
                }
                FillCompetitorsReferences(comps);
            }
            if (dto.Schedule != null)
            {
                _scheduleUrns = new ReadOnlyCollection <URN>(dto.Schedule.Select(s => s.Id).ToList());
            }
            if (dto.CurrentRound != null)
            {
                if (_round == null)
                {
                    _round = new RoundCI(dto.CurrentRound, culture);
                }
                else
                {
                    _round.Merge(dto.CurrentRound, culture);
                }
            }
            if (!string.IsNullOrEmpty(dto.Year))
            {
                _year = dto.Year;
            }
            if (dto.TournamentInfo != null)
            {
                if (_tournamentInfoBasic == null)
                {
                    _tournamentInfoBasic = new TournamentInfoBasicCI(dto.TournamentInfo, culture, DataRouterManager);
                }
                else
                {
                    _tournamentInfoBasic.Merge(dto.TournamentInfo, culture);
                }
            }
            if (dto.SeasonCoverage != null)
            {
                _seasonCoverage = new SeasonCoverageCI(dto.SeasonCoverage);
            }

            if (dto.ExhibitionGames != null)
            {
                _exhibitionGames = dto.ExhibitionGames;
            }
        }