예제 #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
        /// <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;
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TeamCompetitor"/> class
 /// </summary>
 /// <param name="ci">A <see cref="TeamCompetitorCI"/> used to create new instance</param>
 /// <param name="culture">A culture of the current instance of <see cref="TeamCompetitorCI"/></param>
 /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to retrieve <see cref="IPlayer"/></param>
 /// <param name="profileCache">A <see cref="IProfileCache"/> used for fetching profile data</param>
 /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
 public TeamCompetitor(TeamCompetitorCI ci,
                       IEnumerable <CultureInfo> culture,
                       ISportEntityFactory sportEntityFactory,
                       IProfileCache profileCache,
                       ICompetitionCI rootCompetitionCI)
     : base(ci, profileCache, culture, sportEntityFactory, rootCompetitionCI)
 {
     Division = ci.Division;
 }
예제 #4
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;
        }
 /// <summary>
 /// Builds the instance of the <see cref="ITeamCompetitor"/> class
 /// </summary>
 /// <param name="teamCompetitorId">A <see cref="URN"/> of the <see cref="TeamCompetitorCI"/> used to create new instance</param>
 /// <param name="cultures">A culture of the current instance of <see cref="TeamCompetitorCI"/></param>
 /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
 /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the build instance will handle potential exceptions</param>
 /// <returns>The constructed <see cref="ITeamCompetitor"/> instance</returns>
 public Task <ITeamCompetitor> BuildTeamCompetitorAsync(URN teamCompetitorId, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI, ExceptionHandlingStrategy exceptionStrategy)
 {
     throw new NotImplementedException();
 }
 public ITeamCompetitor BuildTeamCompetitor(TeamCompetitorCI teamCompetitorCI, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI, ExceptionHandlingStrategy exceptionStrategy)
 {
     throw new NotImplementedException();
 }
 public ICompetitor BuildCompetitor(CompetitorCI competitorCI, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI, ExceptionHandlingStrategy exceptionStrategy)
 {
     return(new Competitor(competitorCI, _profileCache, cultures, this, exceptionStrategy, rootCompetitionCI));
 }
예제 #8
0
 /// <summary>
 /// Builds the instance of the <see cref="ICompetitor"/> class
 /// </summary>
 /// <param name="competitorId">A <see cref="URN"/> of the <see cref="CompetitorCI"/> used to create new instance</param>
 /// <param name="cultures">A cultures of the current instance of <see cref="CompetitorCI"/></param>
 /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
 /// <returns>The constructed <see cref="ICompetitor"/> instance</returns>
 public Task <ICompetitor> BuildCompetitorAsync(URN competitorId, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI)
 {
     throw new NotImplementedException();
 }
예제 #9
0
 public ITeamCompetitor BuildTeamCompetitor(TeamCompetitorCI ci, IEnumerable <CultureInfo> culture, ICompetitionCI rootCompetitionCI)
 {
     throw new NotImplementedException();
 }
예제 #10
0
 public ICompetitor BuildCompetitor(CompetitorCI ci, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI)
 {
     return(new Competitor(ci, null, cultures, this, rootCompetitionCI));
 }
        /// <summary>
        /// Builds the instance of the <see cref="ITeamCompetitor"/> class
        /// </summary>
        /// <param name="teamCompetitorId">A <see cref="URN"/> of the <see cref="TeamCompetitorCI"/> used to create new instance</param>
        /// <param name="cultures">A culture of the current instance of <see cref="TeamCompetitorCI"/></param>
        /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the build instance will handle potential exceptions</param>
        /// <returns>The constructed <see cref="ITeamCompetitor"/> instance</returns>
        public async Task <ITeamCompetitor> BuildTeamCompetitorAsync(URN teamCompetitorId, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI, ExceptionHandlingStrategy exceptionStrategy)
        {
            var cultureInfos = cultures.ToList();
            var competitorCI = await _profileCache.GetCompetitorProfileAsync(teamCompetitorId, cultureInfos).ConfigureAwait(false);

            var teamCompetitorCI = competitorCI as TeamCompetitorCI;

            if (teamCompetitorCI != null)
            {
                return(BuildTeamCompetitor(teamCompetitorCI, cultureInfos, rootCompetitionCI, exceptionStrategy));
            }
            if (competitorCI != null)
            {
                var teamCI = new TeamCompetitorCI(competitorCI);
                return(BuildTeamCompetitor(teamCI, cultureInfos, rootCompetitionCI, exceptionStrategy));
            }
            return(null);
        }
 public ITeamCompetitor BuildTeamCompetitor(TeamCompetitorCI teamCompetitorCI, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI, ExceptionHandlingStrategy exceptionStrategy)
 {
     return(new TeamCompetitor(teamCompetitorCI, cultures, this, exceptionStrategy, _profileCache, rootCompetitionCI));
 }
예제 #13
0
        /// <summary>
        /// Builds the instance of the <see cref="ITeamCompetitor"/> class
        /// </summary>
        /// <param name="teamCompetitorId">A <see cref="URN"/> of the <see cref="TeamCompetitorCI"/> used to create new instance</param>
        /// <param name="cultures">A culture of the current instance of <see cref="TeamCompetitorCI"/></param>
        /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
        /// <returns>The constructed <see cref="ITeamCompetitor"/> instance</returns>
        public async Task <ITeamCompetitor> BuildTeamCompetitorAsync(URN teamCompetitorId, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI)
        {
            var cultureInfos = cultures.ToList();
            var competitorCI = await _profileCache.GetCompetitorProfileAsync(teamCompetitorId, cultureInfos).ConfigureAwait(false);

            var teamCompetitorCI = competitorCI as TeamCompetitorCI;

            if (teamCompetitorCI != null)
            {
                return(BuildTeamCompetitor(teamCompetitorCI, cultureInfos, rootCompetitionCI));
            }
            if (competitorCI != null)
            {
                ExecutionLog.LogWarning($"Transforming CompetitorCI to TeamCompetitorCI for {teamCompetitorId}");
                var teamCI = new TeamCompetitorCI(competitorCI);
                return(BuildTeamCompetitor(teamCI, cultureInfos, rootCompetitionCI));
            }
            return(null);
        }
예제 #14
0
        /// <summary>
        /// Builds the instance of the <see cref="ICompetitor"/> class
        /// </summary>
        /// <param name="competitorId">A <see cref="URN"/> of the <see cref="CompetitorCI"/> used to create new instance</param>
        /// <param name="cultures">A cultures of the current instance of <see cref="CompetitorCI"/></param>
        /// <param name="rootCompetitionCI">A root <see cref="CompetitionCI"/> to which this competitor belongs to</param>
        /// <returns>The constructed <see cref="ICompetitor"/> instance</returns>
        public async Task <ICompetitor> BuildCompetitorAsync(URN competitorId, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI)
        {
            var cultureInfos = cultures.ToList();
            var competitorCI = await _profileCache.GetCompetitorProfileAsync(competitorId, cultureInfos).ConfigureAwait(false);

            if (competitorCI != null)
            {
                return(BuildCompetitor(competitorCI, cultureInfos, rootCompetitionCI));
            }
            return(null);
        }
예제 #15
0
 public ITeamCompetitor BuildTeamCompetitor(TeamCompetitorCI ci, IEnumerable <CultureInfo> cultures, ICompetitionCI rootCompetitionCI)
 {
     return(new TeamCompetitor(ci, cultures, this, _profileCache, rootCompetitionCI));
 }