Exemplo n.º 1
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;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketDescriptionManager"/> class
        /// </summary>
        /// <param name="config">The <see cref="IOddsFeedConfigurationInternal"/> representing feed configuration</param>
        /// <param name="marketCacheProvider">A <see cref="IMarketCacheProvider"/> used to get market descriptions</param>
        /// <param name="invariantMarketDescriptionCache">A <see cref="IMarketDescriptionCache"/> used to get invariant market descriptions</param>
        /// <param name="variantDescriptionListCache">A <see cref="IVariantDescriptionCache"/> used to reload variant market descriptions</param>
        /// <param name="variantDescriptionCache">A <see cref="IMarketDescriptionCache"/> used to access market variant cache (singles)</param>
        public MarketDescriptionManager(IOddsFeedConfigurationInternal config,
                                        IMarketCacheProvider marketCacheProvider,
                                        IMarketDescriptionCache invariantMarketDescriptionCache,
                                        IVariantDescriptionCache variantDescriptionListCache,
                                        IMarketDescriptionCache variantDescriptionCache)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (marketCacheProvider == null)
            {
                throw new ArgumentNullException(nameof(marketCacheProvider));
            }
            if (invariantMarketDescriptionCache == null)
            {
                throw new ArgumentNullException(nameof(invariantMarketDescriptionCache));
            }
            if (variantDescriptionCache == null)
            {
                throw new ArgumentNullException(nameof(variantDescriptionCache));
            }

            _config = config;
            _marketCacheProvider             = marketCacheProvider;
            _invariantMarketDescriptionCache = invariantMarketDescriptionCache as InvariantMarketDescriptionCache;
            _variantDescriptionListCache     = variantDescriptionListCache;
            _exceptionHandlingStrategy       = config.ExceptionHandlingStrategy;
            _variantDescriptionCache         = variantDescriptionCache;

            if (_invariantMarketDescriptionCache == null)
            {
                throw new ArgumentException(nameof(invariantMarketDescriptionCache));
            }
        }
Exemplo 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(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;
        }
 public AdvancedMessageProcessingWorker(IQueueConsumer consumer, Action <T> callbackAction,
                                        ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                        int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0)
     : base(consumer, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds)
 {
     _callbackAction = callbackAction;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FeedMessageMapper" /> class
        /// </summary>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> implementation used to construct <see cref="ISportEvent"/> instances</param>
        /// <param name="nameProviderFactory">A <see cref="INameProviderFactory"/> instance used build <see cref="INameProvider"/> instances used to get/create market/outcome names</param>
        /// <param name="mappingProviderFactory">A factory used to construct <see cref="IMarketMappingProvider"/> instances</param>
        /// <param name="namedValuesProvider">A <see cref="INamedValuesProvider"/> used to obtain descriptions for named values</param>
        /// <param name="externalExceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the publicly available instance constructed by current instance should handle potential exceptions</param>
        /// <param name="producerManager">An <see cref="IProducerManager"/> used to get <see cref="IProducer"/></param>
        /// <param name="marketCacheProvider">The SDK market cache provider used to retrieve market data</param>
        /// <param name="voidReasonCache">A <see cref="INamedValueCache"/> for possible void reasons</param>
        public FeedMessageMapper(ISportEntityFactory sportEntityFactory,
                                 INameProviderFactory nameProviderFactory,
                                 IMarketMappingProviderFactory mappingProviderFactory,
                                 INamedValuesProvider namedValuesProvider,
                                 ExceptionHandlingStrategy externalExceptionStrategy,
                                 IProducerManager producerManager,
                                 IMarketCacheProvider marketCacheProvider,
                                 INamedValueCache voidReasonCache)
        {
            Guard.Argument(sportEntityFactory, nameof(sportEntityFactory)).NotNull();
            Guard.Argument(nameProviderFactory, nameof(nameProviderFactory)).NotNull();
            Guard.Argument(namedValuesProvider, nameof(namedValuesProvider)).NotNull();
            Guard.Argument(producerManager, nameof(producerManager)).NotNull();
            Guard.Argument(marketCacheProvider, nameof(marketCacheProvider)).NotNull();
            Guard.Argument(voidReasonCache, nameof(voidReasonCache)).NotNull();

            _nameProviderFactory       = nameProviderFactory;
            _sportEntityFactory        = sportEntityFactory;
            _mappingProviderFactory    = mappingProviderFactory;
            _namedValuesProvider       = namedValuesProvider;
            _externalExceptionStrategy = externalExceptionStrategy;
            _producerManager           = producerManager;
            _marketCacheProvider       = marketCacheProvider;
            _voidReasonCache           = voidReasonCache;
        }
        /// <summary>
        /// Sets the general configuration properties to values read from configuration file. Only value which can be set
        /// through <see cref="IConfigurationBuilderBase{T}" /> methods are set.
        /// Any values already set by methods on the current instance are overridden
        /// </summary>
        /// <param name="section">A <see cref="IOddsFeedConfigurationSection"/> from which to load the config</param>
        /// <returns>T.</returns>
        internal virtual void LoadFromConfigFile(IOddsFeedConfigurationSection section)
        {
            Guard.Argument(section, nameof(section)).NotNull();

            Section = section;

            if (!string.IsNullOrEmpty(section.SupportedLanguages))
            {
                var langCodes = section.SupportedLanguages.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                SetSupportedLanguages(langCodes.Select(langCode => new CultureInfo(langCode.Trim())));
            }

            if (!string.IsNullOrEmpty(section.DefaultLanguage))
            {
                SetDefaultLanguage(new CultureInfo(section.DefaultLanguage.Trim()));
            }
            ExceptionHandlingStrategy = section.ExceptionHandlingStrategy;
            NodeId = section.NodeId;
            if (!string.IsNullOrEmpty(section.DisabledProducers))
            {
                var producerIds = section.DisabledProducers.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                SetDisabledProducers(producerIds.Select(producerId => int.Parse(producerId.Trim())));
            }

            HttpClientTimeout = section.HttpClientTimeout;
        }
Exemplo n.º 7
0
        private void Setup(ExceptionHandlingStrategy exceptionStrategy)
        {
            var dataFetcher = new TestDataFetcher();

            _fetcherMock = new Mock <IDataFetcher>();

            _enMatchStatusUri = new Uri(TestData.RestXmlPath + @"\match_status_descriptions.en.xml", UriKind.Absolute);
            _fetcherMock.Setup(args => args.GetDataAsync(_enMatchStatusUri))
            .Returns(dataFetcher.GetDataAsync(_enMatchStatusUri));

            _deMatchStatusUri = new Uri(TestData.RestXmlPath + @"\match_status_descriptions.de.xml", UriKind.Absolute);
            _fetcherMock.Setup(args => args.GetDataAsync(_deMatchStatusUri))
            .Returns(dataFetcher.GetDataAsync(_deMatchStatusUri));

            _huMatchStatusUri = new Uri(TestData.RestXmlPath + @"\match_status_descriptions.hu.xml", UriKind.Absolute);
            _fetcherMock.Setup(args => args.GetDataAsync(_huMatchStatusUri))
            .Returns(dataFetcher.GetDataAsync(_huMatchStatusUri));

            _nlMatchStatusUri = new Uri(TestData.RestXmlPath + @"\match_status_descriptions.nl.xml", UriKind.Absolute);
            _fetcherMock.Setup(args => args.GetDataAsync(_nlMatchStatusUri))
            .Returns(dataFetcher.GetDataAsync(_nlMatchStatusUri));

            var uriFormat = TestData.RestXmlPath + @"\match_status_descriptions.{0}.xml";

            _cache = new LocalizedNamedValueCache(new NamedValueDataProvider(uriFormat, _fetcherMock.Object, "match_status"),
                                                  new[] { new CultureInfo("en"), new CultureInfo("de"), new CultureInfo("hu") }, exceptionStrategy);
        }
        /// <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;
                }
            }
        }
 public AdvancedProcessingWorker(IQueueConsumer consumer, Action <T, RabbitMQConsumerContext> callbackAction,
                                 ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                 int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0, ILogger logger = null)
     : base(consumer, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds, logger)
 {
     _callbackAction = callbackAction;
 }
Exemplo n.º 10
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;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FeedMessageMapper" /> class
        /// </summary>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> implementation used to construct <see cref="ISportEvent"/> instances</param>
        /// <param name="nameProviderFactory">A <see cref="INameProviderFactory"/> instance used build <see cref="INameProvider"/> instances used to get/create market/outcome names</param>
        /// <param name="mappingProviderFactory">A factory used to construct <see cref="IMarketMappingProvider"/> instances</param>
        /// <param name="namedValuesProvider">A <see cref="INamedValuesProvider"/> used to obtain descriptions for named values</param>
        /// <param name="externalExceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the publicly available instance constructed by current instance should handle potential exceptions</param>
        /// <param name="producerManager">An <see cref="IProducerManager"/> used to get <see cref="IProducer"/></param>
        /// <param name="marketCacheProvider">The SDK market cache provider used to retrieve market data</param>
        /// <param name="voidReasonCache">A <see cref="INamedValueCache"/> for possible void reasons</param>
        public FeedMessageMapper(ISportEntityFactory sportEntityFactory,
                                 INameProviderFactory nameProviderFactory,
                                 IMarketMappingProviderFactory mappingProviderFactory,
                                 INamedValuesProvider namedValuesProvider,
                                 ExceptionHandlingStrategy externalExceptionStrategy,
                                 IProducerManager producerManager,
                                 IMarketCacheProvider marketCacheProvider,
                                 INamedValueCache voidReasonCache)
        {
            Contract.Requires(sportEntityFactory != null);
            Contract.Requires(nameProviderFactory != null);
            Contract.Requires(namedValuesProvider != null);
            Contract.Requires(producerManager != null);
            Contract.Requires(marketCacheProvider != null);
            Contract.Requires(voidReasonCache != null);

            _nameProviderFactory       = nameProviderFactory;
            _sportEntityFactory        = sportEntityFactory;
            _mappingProviderFactory    = mappingProviderFactory;
            _namedValuesProvider       = namedValuesProvider;
            _externalExceptionStrategy = externalExceptionStrategy;
            _producerManager           = producerManager;
            _marketCacheProvider       = marketCacheProvider;
            _voidReasonCache           = voidReasonCache;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Group"/> class
        /// </summary>
        /// <param name="ci">A <see cref="GroupCI"/> used to create new instance</param>
        /// <param name="cultures">A culture of the current instance of <see cref="GroupDTO"/></param>
        /// <param name="sportEntityFactory">A <see cref="ISportEntityFactory"/> used to retrieve <see cref="IPlayerProfile"/></param>
        /// <param name="exceptionStrategy">The exception strategy</param>
        /// <param name="competitorsReferenceIds">A list of <see cref="ReferenceIdCI"/> for all competitors</param>
        public Group(GroupCI ci,
                     IEnumerable <CultureInfo> cultures,
                     ISportEntityFactory sportEntityFactory,
                     ExceptionHandlingStrategy exceptionStrategy,
                     IDictionary <URN, ReferenceIdCI> competitorsReferenceIds)
        {
            Guard.Argument(ci, nameof(ci)).NotNull();

            Id   = ci.Id;
            Name = ci.Name;
            if (ci.Competitors != null)
            {
                //var competitors = new List<ICompetitor>();
                //var cultureInfos = cultures.ToList();
                //foreach (CompetitorCI competitorCI in ci.Competitors)
                //{
                //    if (competitorCI == null)
                //    {
                //        var x = "2";
                //    }
                //    var comp = new Competitor(competitorCI, cultureInfos, sportEntityFactory, competitorsReferenceIds);
                //    competitors.Add(comp);
                //}
                //_competitors = competitors;
                _competitors = ci.Competitors.Select(t => sportEntityFactory.BuildCompetitor(t, cultures, competitorsReferenceIds, exceptionStrategy)).ToList();
            }
        }
Exemplo n.º 13
0
 public TestSection(string accessToken, int inactivitySeconds, string host, string virtualHost, int port, string username, string password, string apiHost, bool useSSL, bool useApiSSL, string supportedLanguages, string defaultLanguage, bool statisticsEnabled, int statisticsTimeout, int statisticsRecordLimit, string sdkLogConfigPath, bool useIntegrationEnvironment, ExceptionHandlingStrategy exceptionHandlingStrategy, string disabledProducers, int maxRecoveryTime, int minIntervalBetweenRecoveryRequests, int nodeId, bool adjustAfterAge, int httpClientTimeout, int recoveryHttpClientTimeout)
 {
     AccessToken       = accessToken;
     InactivitySeconds = inactivitySeconds;
     Host                               = host;
     VirtualHost                        = virtualHost;
     Port                               = port;
     Username                           = username;
     Password                           = password;
     ApiHost                            = apiHost;
     UseSSL                             = useSSL;
     UseApiSSL                          = useApiSSL;
     SupportedLanguages                 = supportedLanguages;
     DefaultLanguage                    = defaultLanguage;
     StatisticsEnabled                  = statisticsEnabled;
     StatisticsTimeout                  = statisticsTimeout;
     StatisticsRecordLimit              = statisticsRecordLimit;
     SdkLogConfigPath                   = sdkLogConfigPath;
     UseIntegrationEnvironment          = useIntegrationEnvironment;
     ExceptionHandlingStrategy          = exceptionHandlingStrategy;
     DisabledProducers                  = disabledProducers;
     MaxRecoveryTime                    = maxRecoveryTime;
     MinIntervalBetweenRecoveryRequests = minIntervalBetweenRecoveryRequests;
     NodeId                             = nodeId;
     AdjustAfterAge                     = adjustAfterAge;
     HttpClientTimeout                  = httpClientTimeout;
     RecoveryHttpClientTimeout          = recoveryHttpClientTimeout;
 }
Exemplo n.º 14
0
        public CurrentSeasonInfo(CurrentSeasonInfoCI cacheItem,
                                 IEnumerable <CultureInfo> cultures,
                                 ISportEntityFactory sportEntityFactory,
                                 ExceptionHandlingStrategy exceptionHandlingStrategy,
                                 IDictionary <URN, ReferenceIdCI> competitorsReferenceIds)
        {
            Guard.Argument(cacheItem, nameof(cacheItem)).NotNull();
            //Guard.Argument(sportEntityFactory, nameof()).NotNull();

            var cultureInfos = cultures as IList <CultureInfo> ?? cultures.ToList();

            Id        = cacheItem.Id;
            Names     = cacheItem.Name as IReadOnlyDictionary <CultureInfo, string>;
            Year      = cacheItem.Year;
            StartDate = cacheItem.StartDate;
            EndDate   = cacheItem.EndDate;
            Coverage  = cacheItem.SeasonCoverage == null
                ? null
                : new SeasonCoverage(cacheItem.SeasonCoverage);
            Groups = cacheItem.Groups == null
                ? null
                : cacheItem.Groups.Select(s => new Group(s, cultureInfos, sportEntityFactory, exceptionHandlingStrategy, competitorsReferenceIds));
            CurrentRound = cacheItem.CurrentRound == null
                ? null
                : new Round(cacheItem.CurrentRound, cultureInfos);
            Competitors = cacheItem.Competitors == null
                ? null
                : cacheItem.Competitors.Select(s => sportEntityFactory.BuildCompetitor(s, cultureInfos, competitorsReferenceIds, exceptionHandlingStrategy));
            Schedule = cacheItem.Schedule == null
                ? null
                : cacheItem.Schedule.Select(s => sportEntityFactory.BuildSportEvent <ISportEvent>(s, null, cultureInfos, exceptionHandlingStrategy));
        }
Exemplo n.º 15
0
        public CurrentSeasonInfo(ITournamentInfoCI currentSeasonCI,
                                 IEnumerable <CultureInfo> cultures,
                                 ISportEntityFactory sportEntityFactory,
                                 ExceptionHandlingStrategy exceptionStrategy,
                                 IDictionary <URN, ReferenceIdCI> competitorsReferenceIds)
        {
            var cultureInfos = cultures as IList <CultureInfo> ?? cultures.ToList();

            Id        = currentSeasonCI.Id;
            Names     = currentSeasonCI.GetNamesAsync(cultureInfos).Result;
            Year      = currentSeasonCI.GetYearAsync().Result;
            StartDate = currentSeasonCI.GetScheduledAsync().Result ?? DateTime.MinValue;
            EndDate   = currentSeasonCI.GetScheduledEndAsync().Result ?? DateTime.MinValue;
            Coverage  = currentSeasonCI.GetSeasonCoverageAsync().Result == null
                ? null
                : new SeasonCoverage(currentSeasonCI.GetSeasonCoverageAsync().Result);
            Groups = currentSeasonCI.GetGroupsAsync(cultureInfos).Result == null
                ? null
                : currentSeasonCI.GetGroupsAsync(cultureInfos).Result.Select(s => new Group(s, cultureInfos, sportEntityFactory, exceptionStrategy, competitorsReferenceIds));
            CurrentRound = currentSeasonCI.GetCurrentRoundAsync(cultureInfos).Result == null
                ? null
                : new Round(currentSeasonCI.GetCurrentRoundAsync(cultureInfos).Result, cultureInfos);
            Competitors = currentSeasonCI.GetCompetitorsAsync(cultureInfos).Result == null
                ? null
                : currentSeasonCI.GetCompetitorsAsync(cultureInfos).Result.Select(s => sportEntityFactory.BuildCompetitor(s, cultureInfos, competitorsReferenceIds, exceptionStrategy));
            Schedule = currentSeasonCI.GetScheduleAsync(cultureInfos).Result == null
                ? null
                : currentSeasonCI.GetScheduleAsync(cultureInfos).Result.Select(s => sportEntityFactory.BuildSportEvent <ISportEvent>(s, null, cultureInfos, exceptionStrategy));
        }
        /// <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="eventStatusCache">A <see cref="ISportEventStatusCache" /> instance used to retrieve event status data</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="producer">An <see cref="IProducer" /> used to get market/outcome mappings</param>
        /// <param name="sportId">A sportId used to get market/outcome mappings</param>
        /// <param name="exceptionStrategy">
        ///     A <see cref="ExceptionHandlingStrategy" /> describing the mode in which the SDK is
        ///     running
        /// </param>
        /// <param name="producerManager">The <see cref="IProducerManager" /> used get available <see cref="IProducer" /></param>
        internal MarketMappingProvider(IMarketCacheProvider marketCacheProvider,
                                       ISportEventStatusCache eventStatusCache,
                                       ISportEvent sportEvent,
                                       int marketId,
                                       IReadOnlyDictionary <string, string> specifiers,
                                       IProducer producer,
                                       URN sportId,
                                       ExceptionHandlingStrategy exceptionStrategy,
                                       IProducerManager producerManager)
        {
            Contract.Requires(marketCacheProvider != null);
            Contract.Requires(sportEvent != null);
            Contract.Requires(eventStatusCache != null);
            Contract.Requires(producerManager != null);

            _marketCacheProvider = marketCacheProvider;
            _eventStatusCache    = eventStatusCache;
            _sportEvent          = sportEvent;
            _marketId            = marketId;
            _specifiers          = specifiers;
            _exceptionStrategy   = exceptionStrategy;
            _producerManager     = producerManager;
            _producer            = producer;
            _sportId             = sportId;
        }
        /// <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="eventStatusCache">A <see cref="ISportEventStatusCache"/> instance used to retrieve event status data</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="producer">An <see cref="IProducer"/> used to get market/outcome mappings</param>
        /// <param name="sportId">A sportId used to get market/outcome mappings</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> describing the mode in which the SDK is running</param>
        /// <param name="producerManager">The <see cref="IProducerManager"/> used get available <see cref="IProducer"/></param>
        internal MarketMappingProvider(IMarketCacheProvider marketCacheProvider,
                                       ISportEventStatusCache eventStatusCache,
                                       ISportEvent sportEvent,
                                       int marketId,
                                       IReadOnlyDictionary <string, string> specifiers,
                                       IProducer producer,
                                       URN sportId,
                                       ExceptionHandlingStrategy exceptionStrategy,
                                       IProducerManager producerManager)
        {
            Guard.Argument(marketCacheProvider, nameof(marketCacheProvider)).NotNull();
            Guard.Argument(sportEvent, nameof(sportEvent)).NotNull();
            Guard.Argument(eventStatusCache, nameof(eventStatusCache)).NotNull();
            Guard.Argument(producerManager, nameof(producerManager)).NotNull();

            _marketCacheProvider = marketCacheProvider;
            _eventStatusCache    = eventStatusCache;
            _sportEvent          = sportEvent;
            _marketId            = marketId;
            _specifiers          = specifiers;
            _exceptionStrategy   = exceptionStrategy;
            _producerManager     = producerManager;
            _producer            = producer;
            _sportId             = sportId;
        }
        /// <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;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NamedValueCache"/> class.
        /// </summary>
        /// <param name="dataProvider">A <see cref="IDataProvider{T}"/> used to get the named values</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how potential exceptions should be handled</param>
        public NamedValueCache(IDataProvider <EntityList <NamedValueDTO> > dataProvider, ExceptionHandlingStrategy exceptionStrategy)
        {
            Contract.Requires(dataProvider != null);

            _dataProvider      = dataProvider;
            _namedValues       = new Dictionary <int, string>();
            _exceptionStrategy = exceptionStrategy;
        }
 public AdvancedProcessingWorker(IQueueConsumer consumer, Action <IEnumerable <T> > batchCallbackAction,
                                 ushort batchSize, ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                 int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0, ILogger logger = null)
     : base(consumer, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds, logger)
 {
     _batchCallbackAction = batchCallbackAction;
     _batchSize           = batchSize;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NamedValueCache"/> class.
        /// </summary>
        /// <param name="dataProvider">A <see cref="IDataProvider{T}"/> used to get the named values</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how potential exceptions should be handled</param>
        public NamedValueCache(IDataProvider <EntityList <NamedValueDTO> > dataProvider, ExceptionHandlingStrategy exceptionStrategy)
        {
            Guard.Argument(dataProvider, nameof(dataProvider)).NotNull();

            _dataProvider      = dataProvider;
            _namedValues       = new Dictionary <int, string>();
            _exceptionStrategy = exceptionStrategy;
        }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Draw"/> class
 /// </summary>
 /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event associated with the current instance</param>
 /// <param name="sportId">A <see cref="URN"/> uniquely identifying the sport associated with the current instance</param>
 /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the initialized instance will handle potential exceptions</param>
 public Draw(URN id,
             URN sportId,
             ISportEventCache sportEventCache,
             IEnumerable <CultureInfo> cultures,
             ExceptionHandlingStrategy exceptionStrategy)
     : base(id, sportId, ExecutionLogPrivate, sportEventCache, cultures, 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="eventStatusCache">A <see cref="ISportEventStatusCache"/> instance used to retrieve event status data</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> specifying how to handle potential exceptions thrown to the user code</param>
        public MarketMappingProviderFactory(IMarketCacheProvider marketCacheProvider, ISportEventStatusCache eventStatusCache, ExceptionHandlingStrategy exceptionStrategy)
        {
            Guard.Argument(marketCacheProvider, nameof(marketCacheProvider)).NotNull();
            Guard.Argument(eventStatusCache, nameof(eventStatusCache)).NotNull();

            _marketCacheProvider = marketCacheProvider;
            _eventStatusCache    = eventStatusCache;
            _exceptionStrategy   = exceptionStrategy;
        }
Exemplo n.º 24
0
 protected AbstractAdvancedMessageProcessingWorker(IQueueConsumer consumer,
                                                   ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                                   int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0)
     : base(consumer)
 {
     InvokeRetryCount            = invokeRetryCount;
     InvokeRetryWaitMilliseconds = invokeRetryWaitMilliseconds;
     ExceptionHandlingStrategy   = exceptionHandlingStrategy;
 }
Exemplo n.º 25
0
 public AdvancedAsyncProcessingWorker(IQueueConsumer consumer,
                                      Func <T, RabbitMQConsumerContext, CancellationToken, Task> callbackFunc, TimeSpan processingTimeout,
                                      ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                      int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0, ILogger logger = null)
     : base(consumer, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds, logger)
 {
     _callbackFunc      = callbackFunc;
     _processingTimeout = processingTimeout;
 }
 public AdvancedAsyncMessageProcessingWorker(IQueueConsumer consumer,
                                             Func <T, CancellationToken, Task> callbackFunc, TimeSpan processingTimeout,
                                             ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                             int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0)
     : base(consumer, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds)
 {
     _callbackFunc      = callbackFunc;
     _processingTimeout = processingTimeout;
 }
 public AdvancedMessageProcessingWorker(IQueueClient queueClient, string queueName, Action <T> callbackAction,
                                        ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                        int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0,
                                        ConsumerCountManager consumerCountManager = null, IMessageRejectionHandler messageRejectionHandler = null)
     : base(queueClient, queueName, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds,
            consumerCountManager, messageRejectionHandler)
 {
     _callbackAction = callbackAction;
 }
Exemplo n.º 28
0
 public AdvancedAsyncProcessingWorker(IQueueConsumer consumer,
                                      Func <IEnumerable <T>, CancellationToken, Task> batchCallbackFunc, ushort batchSize, TimeSpan processingTimeout,
                                      ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                      int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0, ILogger logger = null)
     : base(consumer, exceptionHandlingStrategy, invokeRetryCount, invokeRetryWaitMilliseconds, logger)
 {
     _batchCallbackFunc = batchCallbackFunc;
     _processingTimeout = processingTimeout;
     _batchSize         = batchSize;
 }
Exemplo n.º 29
0
 protected AbstractAdvancedMessageProcessingWorker(IQueueClient queueClient, string queueName,
                                                   ExceptionHandlingStrategy exceptionHandlingStrategy = ExceptionHandlingStrategy.Requeue,
                                                   int invokeRetryCount = 1, int invokeRetryWaitMilliseconds = 0,
                                                   ConsumerCountManager consumerCountManager = null, IMessageRejectionHandler messageRejectionHandler = null)
     : base(queueClient, queueName, consumerCountManager, messageRejectionHandler)
 {
     InvokeRetryCount            = invokeRetryCount;
     InvokeRetryWaitMilliseconds = invokeRetryWaitMilliseconds;
     ExceptionHandlingStrategy   = exceptionHandlingStrategy;
 }
Exemplo n.º 30
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="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> used in sport entity factory</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,
                       ExceptionHandlingStrategy exceptionStrategy,
                       IProfileCache profileCache,
                       ICompetitionCI rootCompetitionCI)
     : base(ci, profileCache, culture, sportEntityFactory, exceptionStrategy, rootCompetitionCI)
 {
     Division = ci.Division;
 }