/// <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; }
/// <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; } } }
/// <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> /// 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; } } }
/// <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; }