/// <summary>
        /// Initializes a new instance of the <see cref="SportDataProvider"/> class
        /// </summary>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to construct <see cref="ITournament"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to retrieve schedules for sport events</param>
        /// <param name="sportEventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve status for sport event</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve competitor or player profile</param>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> used to retrieve sport data</param>
        /// <param name="defaultCultures"> A <see cref="IList{CultureInfo}"/> specified as default cultures (from configuration)</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying enum member specifying how instances provided by the current provider will handle exceptions</param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="dataRouterManager">A <see cref="IDataRouterManager"/> used to invoke API requests</param>
        public SportDataProvider(ISportEntityFactory sportEntityFactory,
                                 ISportEventCache sportEventCache,
                                 ISportEventStatusCache sportEventStatusCache,
                                 IProfileCache profileCache,
                                 ISportDataCache sportDataCache,
                                 IEnumerable <CultureInfo> defaultCultures,
                                 ExceptionHandlingStrategy exceptionStrategy,
                                 ICacheManager cacheManager,
                                 ILocalizedNamedValueCache matchStatusCache,
                                 IDataRouterManager dataRouterManager)
        {
            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(defaultCultures, nameof(defaultCultures)).NotNull().NotEmpty();
            Guard.Argument(cacheManager, nameof(cacheManager)).NotNull();
            Guard.Argument(matchStatusCache, nameof(matchStatusCache)).NotNull();
            Guard.Argument(dataRouterManager, nameof(dataRouterManager)).NotNull();

            _sportEntityFactory    = sportEntityFactory;
            _sportEventCache       = sportEventCache;
            _sportEventStatusCache = sportEventStatusCache;
            _profileCache          = profileCache;
            _sportDataCache        = sportDataCache;
            _defaultCultures       = defaultCultures as IReadOnlyCollection <CultureInfo>;
            _exceptionStrategy     = exceptionStrategy;
            _cacheManager          = cacheManager;
            _matchStatusCache      = matchStatusCache;
            _dataRouterManager     = dataRouterManager;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportDataProvider"/> class
        /// </summary>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to construct <see cref="ITournament"/> instances</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> used to retrieve schedules for sport events</param>
        /// <param name="sportEventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve status for sport event</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> ued to retrieve competitor or player profile</param>
        /// <param name="defaultCultures"> A <see cref="IList{CultureInfo}"/> specified as default cultures (from configuration)</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying enum member specifying how instances provided by the current provider will handle exceptions</param>
        /// <param name="cacheManager">A <see cref="ICacheManager"/> used to interact among caches</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        public SportDataProvider(ISportEntityFactory sportEntityFactory,
                                 ISportEventCache sportEventCache,
                                 ISportEventStatusCache sportEventStatusCache,
                                 IProfileCache profileCache,
                                 IEnumerable <CultureInfo> defaultCultures,
                                 ExceptionHandlingStrategy exceptionStrategy,
                                 ICacheManager cacheManager,
                                 ILocalizedNamedValueCache matchStatusCache,
                                 IDataRouterManager dataRouterManager)
        {
            Contract.Requires(sportEntityFactory != null);
            Contract.Requires(sportEventCache != null);
            Contract.Requires(profileCache != null);
            Contract.Requires(defaultCultures != null);
            Contract.Requires(defaultCultures.Any());
            Contract.Requires(cacheManager != null);
            Contract.Requires(matchStatusCache != null);
            Contract.Requires(dataRouterManager != null);

            _sportEntityFactory    = sportEntityFactory;
            _sportEventCache       = sportEventCache;
            _sportEventStatusCache = sportEventStatusCache;
            _profileCache          = profileCache;
            _defaultCultures       = defaultCultures as IReadOnlyCollection <CultureInfo>;
            _exceptionStrategy     = exceptionStrategy;
            _cacheManager          = cacheManager;
            _matchStatusCache      = matchStatusCache;
            _dataRouterManager     = dataRouterManager;
        }
Esempio n. 3
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;
        }
Esempio n. 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="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;
        }
Esempio n. 5
0
 public void Init()
 {
     _memoryCache       = new MemoryCache("test");
     _cacheManager      = new CacheManager();
     _dataRouterManager = new TestDataRouterManager(_cacheManager);
     _profileCache      = new ProfileCache(_memoryCache, _dataRouterManager, _cacheManager);
 }
        /// <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;
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrdinalNameExpression"/> class.
        /// </summary>
        /// <param name="profileCache">A <see cref="IProfileCache"/> instance used to fetch player profiles</param>
        /// <param name="operand">A <see cref="IOperand"/> representing part of the name expression</param>
        internal PlayerProfileExpression(IProfileCache profileCache, IOperand operand)
        {
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(operand, nameof(operand)).NotNull();

            _profileCache = profileCache;
            _operand      = operand;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NameExpressionFactory"/> class
        /// </summary>
        /// <param name="operandFactory">A <see cref="IOperandFactory"/> used to build <see cref="IOperand"/> instances required by name expressions</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to fetch profiles</param>
        public NameExpressionFactory(IOperandFactory operandFactory, IProfileCache profileCache)
        {
            Guard.Argument(operandFactory, nameof(operandFactory)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();

            _operandFactory = operandFactory;
            _profileCache   = profileCache;
        }
 protected ProfileCacheManagerBase(ILogger log, IProfileCache profileCache, IProfileProvider profileProvider)
     : base(log)
 {
     ProfileProvider = profileProvider;
     ProfileCache = profileCache;
     CounterMax = CounterMaxDefault;
     ProfileMaxCount = ProfileMaxCountDefault;
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="NameExpressionFactory" /> class
        /// </summary>
        /// <param name="operandFactory">
        ///     A <see cref="IOperandFactory" /> used to build <see cref="IOperand" /> instances required
        ///     by name expressions
        /// </param>
        /// <param name="profileCache">A <see cref="IProfileCache" /> used to fetch profiles</param>
        public NameExpressionFactory(IOperandFactory operandFactory, IProfileCache profileCache)
        {
            Contract.Requires(operandFactory != null);
            Contract.Requires(profileCache != null);

            _operandFactory = operandFactory;
            _profileCache   = profileCache;
        }
Esempio n. 11
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="OrdinalNameExpression" /> class.
        /// </summary>
        /// <param name="profileCache">A <see cref="IProfileCache" /> instance used to fetch player profiles</param>
        /// <param name="operand">A <see cref="IOperand" /> representing part of the name expression</param>
        internal PlayerProfileExpression(IProfileCache profileCache, IOperand operand)
        {
            Contract.Requires(profileCache != null);
            Contract.Requires(operand != null);

            _profileCache = profileCache;
            _operand      = operand;
        }
Esempio n. 12
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;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="NameProviderFactory"/> class.
        /// </summary>
        /// <param name="marketCacheProvider">A <see cref="IMarketCacheProvider"/> instance used to retrieve market descriptors</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> instance used to retrieve player and competitor profiles</param>
        /// <param name="expressionFactory">A <see cref="INameExpressionFactory"/> instance used to built <see cref="INameExpression"/> instances</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> specifying how to handle potential exceptions thrown to the user code</param>
        public NameProviderFactory(IMarketCacheProvider marketCacheProvider, IProfileCache profileCache, INameExpressionFactory expressionFactory, ExceptionHandlingStrategy exceptionStrategy)
        {
            Guard.Argument(marketCacheProvider, nameof(marketCacheProvider)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(expressionFactory, nameof(expressionFactory)).NotNull();

            _marketCacheProvider = marketCacheProvider;
            _profileCache        = profileCache;
            _expressionFactory   = expressionFactory;
            _exceptionStrategy   = exceptionStrategy;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NameProviderFactory"/> class.
        /// </summary>
        /// <param name="marketCacheProvider">A <see cref="IMarketCacheProvider"/> instance used to retrieve market descriptors</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> instance used to retrieve player and competitor profiles</param>
        /// <param name="expressionFactory">A <see cref="INameExpressionFactory"/> instance used to built <see cref="INameExpression"/> instances</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> specifying how to handle potential exceptions thrown to the user code</param>
        public NameProviderFactory(IMarketCacheProvider marketCacheProvider, IProfileCache profileCache, INameExpressionFactory expressionFactory, ExceptionHandlingStrategy exceptionStrategy)
        {
            Contract.Requires(marketCacheProvider != null);
            Contract.Requires(profileCache != null);
            Contract.Requires(expressionFactory != null);

            _marketCacheProvider = marketCacheProvider;
            _profileCache        = profileCache;
            _expressionFactory   = expressionFactory;
            _exceptionStrategy   = exceptionStrategy;
        }
Esempio n. 15
0
        public AccountQuery(IAccountStore accountStore, IProfileStore profileStore, IAccountCache accountCache, IProfileCache profileCache)
        {
            Ensure.Any.IsNotNull(accountStore, nameof(accountStore));
            Ensure.Any.IsNotNull(profileStore, nameof(profileStore));
            Ensure.Any.IsNotNull(accountCache, nameof(accountCache));
            Ensure.Any.IsNotNull(profileCache, nameof(profileCache));

            _accountStore = accountStore;
            _profileStore = profileStore;
            _accountCache = accountCache;
            _profileCache = profileCache;
        }
Esempio n. 16
0
        public ProfileQuery(
            IProfileStore store,
            IProfileCache cache,
            ICategoryQuery query)
        {
            Ensure.Any.IsNotNull(store, nameof(store));
            Ensure.Any.IsNotNull(cache, nameof(cache));
            Ensure.Any.IsNotNull(query, nameof(query));

            _store = store;
            _cache = cache;
            _query = query;
        }
Esempio n. 17
0
        public void Init()
        {
            _memoryCache       = new MemoryCache("cache");
            _cacheManager      = new CacheManager();
            _dataRouterManager = new TestDataRouterManager(_cacheManager);
            _profileCache      = new ProfileCache(_memoryCache, _dataRouterManager, _cacheManager);

            _nameProvider = new NameProvider(
                new Mock <IMarketCacheProvider>().Object,
                _profileCache,
                new Mock <INameExpressionFactory>().Object,
                new Mock <ISportEvent>().Object,
                1,
                null,
                ExceptionHandlingStrategy.THROW);
        }
Esempio n. 18
0
        public ProfileCommand(
            IProfileStore store,
            IProfileChangeCalculator calculator,
            IProfileChangeProcessor processor,
            IProfileCache cache)
        {
            Ensure.Any.IsNotNull(store, nameof(store));
            Ensure.Any.IsNotNull(calculator, nameof(calculator));
            Ensure.Any.IsNotNull(processor, nameof(processor));
            Ensure.Any.IsNotNull(cache, nameof(cache));

            _store      = store;
            _calculator = calculator;
            _processor  = processor;
            _cache      = cache;
        }
        public TestSportEntityFactory(ISportDataCache sportDataCache             = null,
                                      ISportEventCache sportEventCache           = null,
                                      ISportEventStatusCache eventStatusCache    = null,
                                      ILocalizedNamedValueCache matchStatusCache = null,
                                      IProfileCache profileCache = null,
                                      IReadOnlyCollection <URN> soccerSportUrns = null)
        {
            _cacheManager = new CacheManager();
            var profileMemoryCache = new MemoryCache("ProfileCache");

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache ?? new ProfileCache(profileMemoryCache, new TestDataRouterManager(_cacheManager), _cacheManager);
            _soccerSportUrns  = soccerSportUrns ?? SdkInfo.SoccerSportUrns;
        }
Esempio n. 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEntityFactory"/> class
        /// </summary>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve sport related info</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance used to retrieve sport events</param>
        /// <param name="eventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve statuses of sport events</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve player profiles</param>
        public SportEntityFactory(
            ISportDataCache sportDataCache,
            ISportEventCache sportEventCache,
            ISportEventStatusCache eventStatusCache,
            ILocalizedNamedValueCache matchStatusCache,
            IProfileCache profileCache)
        {
            Contract.Requires(sportDataCache != null);
            Contract.Requires(sportEventCache != null);
            Contract.Requires(eventStatusCache != null);
            Contract.Requires(matchStatusCache != null);
            Contract.Requires(profileCache != null);

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache;
        }
Esempio n. 21
0
        public ProfileSearchQuery(
            ICategoryQuery query,
            IProfileStore profileStore,
            ICategoryLinkStore linkStore,
            IProfileCache profileCache,
            ICategoryCache cache)
        {
            Ensure.Any.IsNotNull(profileStore, nameof(profileStore));
            Ensure.Any.IsNotNull(linkStore, nameof(linkStore));
            Ensure.Any.IsNotNull(cache, nameof(cache));
            Ensure.Any.IsNotNull(query, nameof(query));
            Ensure.Any.IsNotNull(profileCache, nameof(profileCache));

            _profileStore = profileStore;
            _linkStore    = linkStore;
            _cache        = cache;
            _query        = query;
            _profileCache = profileCache;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEntityFactory"/> class
        /// </summary>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve sport related info</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance used to retrieve sport events</param>
        /// <param name="eventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve statuses of sport events</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve player profiles</param>
        public SportEntityFactory(
            ISportDataCache sportDataCache,
            ISportEventCache sportEventCache,
            ISportEventStatusCache eventStatusCache,
            ILocalizedNamedValueCache matchStatusCache,
            IProfileCache profileCache)
        {
            Guard.Argument(sportDataCache, nameof(sportDataCache)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(eventStatusCache, nameof(eventStatusCache)).NotNull();
            Guard.Argument(matchStatusCache, nameof(matchStatusCache)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache;
        }
        /// <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="SportEntityFactory"/> class
        /// </summary>
        /// <param name="sportDataCache">A <see cref="ISportDataCache"/> instance used to retrieve sport related info</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance used to retrieve sport events</param>
        /// <param name="eventStatusCache">A <see cref="ISportEventStatusCache"/> used to retrieve statuses of sport events</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve match statuses</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> used to retrieve player profiles</param>
        /// <param name="soccerSportUrns">A list of sport urns that have soccer matches</param>
        public SportEntityFactory(ISportDataCache sportDataCache,
                                  ISportEventCache sportEventCache,
                                  ISportEventStatusCache eventStatusCache,
                                  ILocalizedNamedValueCache matchStatusCache,
                                  IProfileCache profileCache,
                                  IReadOnlyCollection <URN> soccerSportUrns)
        {
            Guard.Argument(sportDataCache, nameof(sportDataCache)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(eventStatusCache, nameof(eventStatusCache)).NotNull();
            Guard.Argument(matchStatusCache, nameof(matchStatusCache)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(soccerSportUrns, nameof(soccerSportUrns)).NotNull();

            _sportDataCache   = sportDataCache;
            _sportEventCache  = sportEventCache;
            _eventStatusCache = eventStatusCache;
            _matchStatusCache = matchStatusCache;
            _profileCache     = profileCache;
            _soccerSportUrns  = soccerSportUrns;
        }
        public ProfileChangeProcessor(
            IProfileStore profileStore,
            ICategoryStore categoryStore,
            ICategoryLinkStore linkStore,
            IEventTrigger eventTrigger,
            IProfileCache profileCache,
            ICategoryCache cache)
        {
            Ensure.Any.IsNotNull(profileStore, nameof(profileStore));
            Ensure.Any.IsNotNull(categoryStore, nameof(categoryStore));
            Ensure.Any.IsNotNull(linkStore, nameof(linkStore));
            Ensure.Any.IsNotNull(profileCache, nameof(profileCache));
            Ensure.Any.IsNotNull(cache, nameof(cache));
            Ensure.Any.IsNotNull(eventTrigger, nameof(eventTrigger));

            _profileStore  = profileStore;
            _categoryStore = categoryStore;
            _linkStore     = linkStore;
            _eventTrigger  = eventTrigger;
            _profileCache  = profileCache;
            _cache         = cache;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NameProvider"/> class
        /// </summary>
        /// <param name="marketCacheProvider">A <see cref="IMarketCacheProvider"/> instance used to retrieve market descriptors</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> instance used to retrieve player and competitor profiles</param>
        /// <param name="expressionFactory">A <see cref="INameExpressionFactory"/> instance used to built <see cref="INameExpression"/> instances</param>
        /// <param name="sportEvent">A <see cref="ISportEvent"/> instance representing associated sport @event</param>
        /// <param name="marketId">A market identifier of the market associated with the constructed instance</param>
        /// <param name="specifiers">A <see cref="IReadOnlyDictionary{String, String}"/> representing specifiers of the associated market</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> describing the mode in which the SDK is running</param>
        internal NameProvider(
            IMarketCacheProvider marketCacheProvider,
            IProfileCache profileCache,
            INameExpressionFactory expressionFactory,
            ISportEvent sportEvent,
            int marketId,
            IReadOnlyDictionary <string, string> specifiers,
            ExceptionHandlingStrategy exceptionStrategy)
        {
            Contract.Requires(marketCacheProvider != null);
            Contract.Requires(profileCache != null);
            Contract.Requires(expressionFactory != null);
            Contract.Requires(sportEvent != null);

            _marketCacheProvider       = marketCacheProvider;
            _profileCache              = profileCache;
            _expressionFactory         = expressionFactory;
            _sportEvent                = sportEvent;
            _marketId                  = marketId;
            _specifiers                = specifiers;
            _exceptionStrategy         = exceptionStrategy;
            _competitorsAlreadyFetched = false;
        }
Esempio n. 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NameProvider"/> class
        /// </summary>
        /// <param name="marketCacheProvider">A <see cref="IMarketCacheProvider"/> instance used to retrieve market descriptors</param>
        /// <param name="profileCache">A <see cref="IProfileCache"/> instance used to retrieve player and competitor profiles</param>
        /// <param name="expressionFactory">A <see cref="INameExpressionFactory"/> instance used to built <see cref="INameExpression"/> instances</param>
        /// <param name="sportEvent">A <see cref="ISportEvent"/> instance representing associated sport @event</param>
        /// <param name="marketId">A market identifier of the market associated with the constructed instance</param>
        /// <param name="specifiers">A <see cref="IReadOnlyDictionary{String, String}"/> representing specifiers of the associated market</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> describing the mode in which the SDK is running</param>
        internal NameProvider(
            IMarketCacheProvider marketCacheProvider,
            IProfileCache profileCache,
            INameExpressionFactory expressionFactory,
            ISportEvent sportEvent,
            int marketId,
            IReadOnlyDictionary <string, string> specifiers,
            ExceptionHandlingStrategy exceptionStrategy)
        {
            Guard.Argument(marketCacheProvider, nameof(marketCacheProvider)).NotNull();
            Guard.Argument(profileCache, nameof(profileCache)).NotNull();
            Guard.Argument(expressionFactory, nameof(expressionFactory)).NotNull();
            Guard.Argument(sportEvent, nameof(sportEvent)).NotNull();

            _marketCacheProvider       = marketCacheProvider;
            _profileCache              = profileCache;
            _expressionFactory         = expressionFactory;
            _sportEvent                = sportEvent;
            _marketId                  = marketId;
            _specifiers                = specifiers;
            _exceptionStrategy         = exceptionStrategy;
            _competitorsAlreadyFetched = false;
        }
Esempio n. 28
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;
        }