示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Competitor"/> class
        /// </summary>
        /// <param name="ci">A <see cref="CompetitorCI"/> used to create new instance</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used for fetching profile data</param>
        /// <param name="cultures">A cultures of the current instance of <see cref="CompetitorCI"/></param>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to retrieve <see cref="IPlayerProfile"/></param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> used in sport entity factory</param>
        /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
        public Competitor(CompetitorCI ci,
                          IProfileCache profileCache,
                          IEnumerable <CultureInfo> cultures,
                          ISportEntityFactory sportEntityFactory,
                          ExceptionHandlingStrategy exceptionStrategy,
                          ICompetitionCI rootCompetitionCI)
            : base(ci.Id, new Dictionary <CultureInfo, string>())
        {
            //Guard.Argument(ci, nameof(ci)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull();//.NotEmpty();
            if (!cultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(cultures));
            }

            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();

            if (ci == null)
            {
                // above contract requirement throws even when ci in fact not null
                throw new ArgumentNullException(nameof(ci));
            }

            _competitorCI       = ci;
            _profileCache       = profileCache;
            _cultures           = cultures.ToList();
            _sportEntityFactory = sportEntityFactory;
            _exceptionStrategy  = exceptionStrategy;
            _competitionCI      = (CompetitionCI)rootCompetitionCI;
            _referenceId        = null;
        }
示例#2
0
        protected void FetchEventCompetitorsReferenceIds()
        {
            lock (_lock)
            {
                if (_competitionCI != null || _competitorCI != null)
                {
                    var task = Task.Run(async() =>
                    {
                        var competitorsReferences = _competitionCI != null
                                                                            ? await _competitionCI.GetCompetitorsReferencesAsync().ConfigureAwait(false)
                                                                            : null;

                        if (competitorsReferences != null && competitorsReferences.Any())
                        {
                            ReferenceIdCI q;
                            if (competitorsReferences.TryGetValue(_competitorCI.Id, out q))
                            {
                                _referenceId = q;
                            }
                        }
                        else
                        {
                            if (GetCompetitor().ReferenceId != null)
                            {
                                _referenceId = GetCompetitor().ReferenceId;
                            }
                        }
                    });
                    task.Wait();
                }
            }
        }
示例#3
0
        /// <summary>
        /// Merges the specified fixture
        /// </summary>
        /// <param name="fixture">The fixture</param>
        /// <param name="culture">The culture</param>
        /// <param name="useLock">Should the lock mechanism be used during merge</param>
        public void MergeFixture(FixtureDTO fixture, CultureInfo culture, bool useLock)
        {
            //Merge(fixture, culture);

            if (useLock)
            {
                lock (MergeLock)
                {
                    if (fixture.ReferenceIds != null)
                    {
                        _referenceId = new ReferenceIdCI(fixture.ReferenceIds);
                    }
                    if (fixture.BookingStatus != null)
                    {
                        _bookingStatus = fixture.BookingStatus;
                    }
                }
            }
            else
            {
                if (fixture.ReferenceIds != null)
                {
                    _referenceId = new ReferenceIdCI(fixture.ReferenceIds);
                }
                if (fixture.BookingStatus != null)
                {
                    _bookingStatus = fixture.BookingStatus;
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Competitor"/> class
        /// </summary>
        /// <param name="competitorId">A competitor id used to create new instance</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used for fetching profile data</param>
        /// <param name="cultures">A cultures of the current instance of <see cref="CompetitorCI"/></param>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to retrieve <see cref="IPlayerProfile"/></param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> used in sport entity factory</param>
        /// <param name="competitorsReferences">A list of <see cref="ReferenceIdCI"/> for all competitors</param>
        public Competitor(URN competitorId,
                          IProfileCache profileCache,
                          IEnumerable <CultureInfo> cultures,
                          ISportEntityFactory sportEntityFactory,
                          ExceptionHandlingStrategy exceptionStrategy,
                          IDictionary <URN, ReferenceIdCI> competitorsReferences)
            : base(competitorId, new Dictionary <CultureInfo, string>())
        {
            Guard.Argument(competitorId, nameof(competitorId)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull();
            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();

            _competitorId       = competitorId;
            _competitorCI       = null;
            _profileCache       = profileCache;
            _cultures           = cultures.ToList();
            _sportEntityFactory = sportEntityFactory;
            _exceptionStrategy  = exceptionStrategy;
            _competitionCI      = null;
            _referenceId        = null;

            if (competitorsReferences != null && competitorsReferences.Any())
            {
                if (competitorsReferences.TryGetValue(competitorId, out var q))
                {
                    _referenceId = q;
                }
            }
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionCI" /> class
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableSportEventCI" /> representing the sport event</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 CompetitionCI(ExportableSportEventCI exportable,
                             IDataRouterManager dataRouterManager,
                             ISemaphorePool semaphorePool,
                             CultureInfo defaultCulture,
                             MemoryCache fixtureTimestampCache)
            : base(exportable, dataRouterManager, semaphorePool, defaultCulture, fixtureTimestampCache)
        {
            Guard.Argument(exportable, nameof(exportable)).NotNull();

            var exportableCompetition = exportable as ExportableCompetitionCI;

            if (exportableCompetition != null)
            {
                _bookingStatus = exportableCompetition.BookingStatus;
                _venue         = exportableCompetition.Venue != null ? new VenueCI(exportableCompetition.Venue) : null;
                _conditions    = exportableCompetition.Conditions != null
                    ? new SportEventConditionsCI(exportableCompetition.Conditions)
                    : null;
                Competitors = exportableCompetition.Competitors != null
                    ? new List <URN>(exportableCompetition.Competitors.Select(URN.Parse))
                    : null;
                _referenceId = exportableCompetition.ReferenceId != null
                    ? new ReferenceIdCI(exportableCompetition.ReferenceId)
                    : null;
                _competitorsQualifiers = exportableCompetition.CompetitorsQualifiers != null
                    ? new Dictionary <URN, string>(
                    exportableCompetition.CompetitorsQualifiers.ToDictionary(c => URN.Parse(c.Key), c => c.Value))
                    : null;
                _competitorsReferences = exportableCompetition.CompetitorsReferences != null
                    ? new Dictionary <URN, ReferenceIdCI>(
                    exportableCompetition.CompetitorsReferences.ToDictionary(c => URN.Parse(c.Key),
                                                                             c => new ReferenceIdCI(c.Value)))
                    : null;
            }
        }
 /// <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;
 }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Competitor"/> class
        /// </summary>
        /// <param name="ci">A <see cref="CompetitorCI"/> used to create new instance</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used for fetching profile data</param>
        /// <param name="cultures">A cultures of the current instance of <see cref="CompetitorCI"/></param>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to retrieve <see cref="IPlayerProfile"/></param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> used in sport entity factory</param>
        /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
        public Competitor(CompetitorCI ci,
                          IProfileCache profileCache,
                          IEnumerable <CultureInfo> cultures,
                          ISportEntityFactory sportEntityFactory,
                          ExceptionHandlingStrategy exceptionStrategy,
                          ICompetitionCI rootCompetitionCI)
            : base(ci.Id, new Dictionary <CultureInfo, string>())
        {
            Guard.Argument(cultures, nameof(cultures)).NotNull();
            if (!cultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(cultures));
            }

            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();

            _competitorId       = ci.Id;
            _competitorCI       = ci;
            _profileCache       = profileCache;
            _cultures           = cultures.ToList();
            _sportEntityFactory = sportEntityFactory;
            _exceptionStrategy  = exceptionStrategy;
            _competitionCI      = (CompetitionCI)rootCompetitionCI;
            _referenceId        = null;
        }
        /// <summary>
        /// Merges the specified fixture
        /// </summary>
        /// <param name="fixture">The fixture</param>
        /// <param name="culture">The culture</param>
        private void ActualMergeFixture(FixtureDTO fixture, CultureInfo culture)
        {
            Merge(new TournamentInfoDTO(fixture), culture, false);

            if (fixture.ReferenceIds != null)
            {
                _referenceId = new ReferenceIdCI(fixture.ReferenceIds);
            }
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Reference"/> class
        /// </summary>
        /// <param name="referenceCI">The reference ci</param>
        public Reference(ReferenceIdCI referenceCI)
        {
            if (referenceCI == null)
            {
                return;
            }

            References     = referenceCI.ReferenceIds;
            BetradarId     = referenceCI.BetradarId;
            BetfairId      = referenceCI.BetfairId;
            RotationNumber = referenceCI.RotationNumber;
            AamsId         = referenceCI.AamsId;
        }
示例#10
0
        /// <summary>
        /// Merges the specified fixtureDTO
        /// </summary>
        /// <param name="fixtureDTO">The fixtureDTO</param>
        /// <param name="culture">The culture</param>
        /// <param name="useLock">Should the lock mechanism be used during merge</param>
        public void MergeFixture(FixtureDTO fixtureDTO, CultureInfo culture, bool useLock)
        {
            if (useLock)
            {
                lock (MergeLock)
                {
                    if (fixtureDTO.ReferenceIds != null)
                    {
                        _referenceId = new ReferenceIdCI(fixtureDTO.ReferenceIds);
                    }
                    if (fixtureDTO.BookingStatus != null)
                    {
                        _bookingStatus = fixtureDTO.BookingStatus;
                    }
                }
            }
            else
            {
                if (fixtureDTO.ReferenceIds != null)
                {
                    _referenceId = new ReferenceIdCI(fixtureDTO.ReferenceIds);
                }
                if (fixtureDTO.BookingStatus != null)
                {
                    _bookingStatus = fixtureDTO.BookingStatus;
                }
            }

            if (!string.IsNullOrEmpty(fixtureDTO.LiveOdds))
            {
                _liveOdds = fixtureDTO.LiveOdds;
            }

            if (fixtureDTO.Type != null)
            {
                _sportEventType = fixtureDTO.Type;
            }

            if (fixtureDTO.StageType != null)
            {
                _stageType = fixtureDTO.StageType;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Competitor"/> class
        /// </summary>
        /// <param name="ci">A <see cref="CompetitorCI"/> used to create new instance</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used for fetching profile data</param>
        /// <param name="cultures">A cultures of the current instance of <see cref="CompetitorCI"/></param>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to retrieve <see cref="IPlayerProfile"/></param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> used in sport entity factory</param>
        /// <param name="competitorsReferences">A list of <see cref="ReferenceIdCI"/> for all competitors</param>
        public Competitor(CompetitorCI ci,
                          IProfileCache profileCache,
                          IEnumerable <CultureInfo> cultures,
                          ISportEntityFactory sportEntityFactory,
                          ExceptionHandlingStrategy exceptionStrategy,
                          IDictionary <URN, ReferenceIdCI> competitorsReferences)
            : base(ci.Id, new Dictionary <CultureInfo, string>())
        {
            //Guard.Argument(ci, nameof()).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();
            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();

            if (ci == null)
            {
                // above contract requirement throws even when ci in fact not null
                throw new ArgumentNullException(nameof(ci));
            }

            _competitorCI       = ci;
            _profileCache       = profileCache;
            _cultures           = cultures.ToList();
            _sportEntityFactory = sportEntityFactory;
            _exceptionStrategy  = exceptionStrategy;
            _competitionCI      = null;
            _referenceId        = null;

            if (competitorsReferences != null && competitorsReferences.Any())
            {
                ReferenceIdCI q;
                if (competitorsReferences.TryGetValue(ci.Id, out q))
                {
                    _referenceId = q;
                }
            }
            else
            {
                if (ci.ReferenceId != null)
                {
                    _referenceId = ci.ReferenceId;
                }
            }
        }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionCI" /> class
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableSportEventCI" /> representing the sport event</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="ObjectCache"/> used to cache the sport events fixture timestamps</param>
        public CompetitionCI(ExportableSportEventCI exportable,
                             IDataRouterManager dataRouterManager,
                             ISemaphorePool semaphorePool,
                             CultureInfo defaultCulture,
                             ObjectCache fixtureTimestampCache)
            : base(exportable, dataRouterManager, semaphorePool, defaultCulture, fixtureTimestampCache)
        {
            var exportableCompetition = exportable as ExportableCompetitionCI;

            if (exportableCompetition != null)
            {
                _bookingStatus = exportableCompetition.BookingStatus;
                _venue         = exportableCompetition.Venue != null ? new VenueCI(exportableCompetition.Venue) : null;
                _conditions    = exportableCompetition.Conditions != null
                    ? new SportEventConditionsCI(exportableCompetition.Conditions)
                    : null;
                Competitors = exportableCompetition.Competitors != null
                    ? new List <URN>(exportableCompetition.Competitors.Select(URN.Parse))
                    : null;
                _referenceId = exportableCompetition.ReferenceId != null
                    ? new ReferenceIdCI(exportableCompetition.ReferenceId)
                    : null;
                _competitorsQualifiers = exportableCompetition.CompetitorsQualifiers != null
                    ? new Dictionary <URN, string>(
                    exportableCompetition.CompetitorsQualifiers.ToDictionary(c => URN.Parse(c.Key), c => c.Value))
                    : null;
                _competitorsReferences = exportableCompetition.CompetitorsReferences != null
                    ? new Dictionary <URN, ReferenceIdCI>(
                    exportableCompetition.CompetitorsReferences.ToDictionary(c => URN.Parse(c.Key),
                                                                             c => new ReferenceIdCI(c.Value)))
                    : null;
                _competitorsVirtual = exportableCompetition.CompetitorsVirtual != null
                                          ? exportableCompetition.CompetitorsVirtual.Select(URN.Parse).ToList()
                                          : new List <URN>();

                _liveOdds       = string.IsNullOrEmpty(exportableCompetition.LiveOdds) ? null : exportableCompetition.LiveOdds;
                _sportEventType = exportableCompetition.SportEventType;
                _stageType      = exportableCompetition.StageType;
            }
        }
示例#13
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Competitor" /> class
        /// </summary>
        /// <param name="ci">A <see cref="CompetitorCI" /> used to create new instance</param>
        /// <param name="profileCache">A <see cref="IProfileCache" /> used for fetching profile data</param>
        /// <param name="cultures">A cultures of the current instance of <see cref="CompetitorCI" /></param>
        /// <param name="sportEntityFactory">
        ///     A <see cref="ISportEntityFactory" /> used to retrieve <see cref="IPlayerProfile" />
        /// </param>
        /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI" /> to which this competitor belongs to</param>
        public Competitor(CompetitorCI ci,
                          IProfileCache profileCache,
                          IEnumerable <CultureInfo> cultures,
                          ISportEntityFactory sportEntityFactory,
                          ICompetitionCI rootCompetitionCI)
            : base(ci.Id, new Dictionary <CultureInfo, string>())
        {
            //Contract.Requires(ci != null);
            Contract.Requires(cultures != null && cultures.Any());
            Contract.Requires(sportEntityFactory != null);

            if (ci == null)
            {
                // above contract requirement throws even when ci in fact not null
                throw new ArgumentNullException(nameof(ci));
            }

            _competitorCI       = ci;
            _profileCache       = profileCache;
            _cultures           = cultures.ToList();
            _sportEntityFactory = sportEntityFactory;
            _competitionCI      = (CompetitionCI)rootCompetitionCI;
            _referenceId        = null;
        }