/// <summary>
        /// Builds and returns a <see cref="IOddsFeedConfiguration" /> instance
        /// </summary>
        /// <returns>The constructed <see cref="IOddsFeedConfiguration" /> instance</returns>
        public override IOddsFeedConfiguration Build()
        {
            PreBuildCheck();

            var config = new OddsFeedConfiguration(AccessToken,
                                                   SdkEnvironment.Custom,
                                                   DefaultLocale,
                                                   SupportedLocales,
                                                   _messagingHost,
                                                   _virtualHost,
                                                   _messagingPort ?? (_useMessagingSsl ? SdkInfo.DefaultHostPort : SdkInfo.DefaultHostPort + 1),
                                                   string.IsNullOrEmpty(_messagingUsername) ? AccessToken : _messagingUsername,
                                                   _messagingPassword,
                                                   _apiHost,
                                                   _useMessagingSsl,
                                                   _useApiSsl,
                                                   InactivitySeconds ?? SdkInfo.MinInactivitySeconds,
                                                   MaxRecoveryTimeInSeconds ?? SdkInfo.MaxRecoveryExecutionInSeconds,
                                                   MinIntervalBetweenRecoveryRequests ?? SdkInfo.DefaultIntervalBetweenRecoveryRequests,
                                                   NodeId,
                                                   DisabledProducers,
                                                   ExceptionHandlingStrategy,
                                                   AdjustAfterAge ?? false,
                                                   HttpClientTimeout ?? SdkInfo.DefaultHttpClientTimeout,
                                                   RecoveryHttpClientTimeout ?? HttpClientTimeout ?? SdkInfo.DefaultHttpClientTimeout,
                                                   Section);

            return(config);
        }
        /// <summary>
        /// Builds and returns a <see cref="T:Sportradar.OddsFeed.SDK.API.IOddsFeedConfiguration" /> instance
        /// </summary>
        /// <returns>The constructed <see cref="T:Sportradar.OddsFeed.SDK.API.IOddsFeedConfiguration" /> instance</returns>
        public override IOddsFeedConfiguration Build()
        {
            PreBuildCheck();

            var config = new OddsFeedConfiguration(
                AccessToken,
                SdkEnvironment.Custom,
                DefaultLocale,
                SupportedLocales,
                _messagingHost,
                _virtualHost,
                _messagingPort == 0
                    ? _useMessagingSsl ? SdkInfo.DefaultHostPort : SdkInfo.DefaultHostPort + 1
                    : _messagingPort,
                string.IsNullOrEmpty(_messagingUsername) ? AccessToken : _messagingUsername,
                _messagingPassword,
                _apiHost,
                _useMessagingSsl,
                _useApiSsl,
                InactivitySeconds,
                MaxRecoveryTimeInSeconds,
                NodeId,
                DisabledProducers,
                ExceptionHandlingStrategy,
                AdjustAfterAge,
                Section);

            return(config);
        }
        public override IOddsFeedConfiguration Build()
        {
            PreBuildCheck();

            var config = new OddsFeedConfiguration(AccessToken,
                                                   SdkEnvironment.Replay,
                                                   DefaultLocale,
                                                   SupportedLocales,
                                                   SdkInfo.ReplayHost,
                                                   null,
                                                   SdkInfo.DefaultHostPort,
                                                   null,
                                                   null,
                                                   null,
                                                   true,
                                                   true,
                                                   SdkInfo.MaxInactivitySeconds,
                                                   SdkInfo.MaxRecoveryExecutionInSeconds,
                                                   NodeId,
                                                   DisabledProducers,
                                                   ExceptionHandlingStrategy,
                                                   false,
                                                   Section);

            return(config);
        }
Example #4
0
        public override IOddsFeedConfiguration Build()
        {
            PreBuildCheck();

            var config = new OddsFeedConfiguration(AccessToken,
                                                   _environment,
                                                   DefaultLocale,
                                                   SupportedLocales,
                                                   _environment == SdkEnvironment.Production ? SdkInfo.ProductionHost : SdkInfo.IntegrationHost,
                                                   null,
                                                   SdkInfo.DefaultHostPort,
                                                   null,
                                                   null,
                                                   _environment == SdkEnvironment.Production ? SdkInfo.ProductionApiHost : SdkInfo.IntegrationApiHost,
                                                   true,
                                                   true,
                                                   InactivitySeconds ?? SdkInfo.MinInactivitySeconds,
                                                   MaxRecoveryTimeInSeconds ?? SdkInfo.MaxRecoveryExecutionInSeconds,
                                                   MinIntervalBetweenRecoveryRequests ?? SdkInfo.DefaultIntervalBetweenRecoveryRequests,
                                                   NodeId,
                                                   DisabledProducers,
                                                   ExceptionHandlingStrategy,
                                                   AdjustAfterAge ?? false,
                                                   HttpClientTimeout ?? SdkInfo.DefaultHttpClientTimeout,
                                                   RecoveryHttpClientTimeout ?? HttpClientTimeout ?? SdkInfo.DefaultHttpClientTimeout,
                                                   Section);

            return(config);
        }
        public override IOddsFeedConfiguration Build()
        {
            PreBuildCheck();

            var config = new OddsFeedConfiguration(
                AccessToken,
                _environment,
                DefaultLocale,
                SupportedLocales,
                _environment == SdkEnvironment.Production ? SdkInfo.ProductionHost : SdkInfo.IntegrationHost,
                null,
                SdkInfo.DefaultHostPort,
                null,
                null,
                _environment == SdkEnvironment.Production ? SdkInfo.ProductionApiHost : SdkInfo.IntegrationApiHost,
                true,
                true,
                InactivitySeconds,
                MaxRecoveryTimeInSeconds,
                NodeId,
                DisabledProducers,
                ExceptionHandlingStrategy,
                AdjustAfterAge,
                Section);

            return(config);
        }
        public override IOddsFeedConfiguration Build()
        {
            PreBuildCheck();

            var mqHost = string.IsNullOrEmpty(Section?.Host)
                             ? EnvironmentManager.GetMqHost(_environment)
                             : Section.Host;
            var apiHost = string.IsNullOrEmpty(Section?.ApiHost)
                              ? EnvironmentManager.GetApiHost(_environment)
                              : Section.ApiHost;

            var config = new OddsFeedConfiguration(AccessToken,
                                                   _environment,
                                                   DefaultLocale,
                                                   SupportedLocales,
                                                   mqHost,
                                                   null,
                                                   EnvironmentManager.DefaultMqHostPort,
                                                   null,
                                                   null,
                                                   apiHost,
                                                   true,
                                                   true,
                                                   InactivitySeconds ?? SdkInfo.MinInactivitySeconds,
                                                   MaxRecoveryTimeInSeconds ?? SdkInfo.MaxRecoveryExecutionInSeconds,
                                                   MinIntervalBetweenRecoveryRequests ?? SdkInfo.DefaultIntervalBetweenRecoveryRequests,
                                                   NodeId,
                                                   DisabledProducers,
                                                   ExceptionHandlingStrategy,
                                                   AdjustAfterAge ?? false,
                                                   HttpClientTimeout ?? SdkInfo.DefaultHttpClientTimeout,
                                                   RecoveryHttpClientTimeout ?? HttpClientTimeout ?? SdkInfo.DefaultHttpClientTimeout,
                                                   Section);

            return(config);
        }
        /// <inheritdoc />
        public IOddsFeedConfiguration BuildFromConfigFile()
        {
            var section = _configurationSectionProvider.GetSection();

            if (string.IsNullOrEmpty(section.AccessToken))
            {
                throw new ConfigurationErrorsException("Missing access token");
            }

            var sdkEnvironment = SdkEnvironment.GlobalIntegration;

            if (section.UfEnvironment != null)
            {
                sdkEnvironment = section.UfEnvironment.Value;
            }
            else if (!section.UseIntegrationEnvironment)
            {
                sdkEnvironment = SdkEnvironment.Production;
            }

            var supportedLanguages = new List <CultureInfo>();

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

            var defaultLanguage = supportedLanguages.Any() ? supportedLanguages.First() : null;

            if (!string.IsNullOrEmpty(section.DefaultLanguage))
            {
                defaultLanguage = new CultureInfo(section.DefaultLanguage);
                if (!supportedLanguages.Contains(defaultLanguage))
                {
                    supportedLanguages.Insert(0, defaultLanguage);
                }
            }

            if (supportedLanguages == null || !supportedLanguages.Any())
            {
                throw new InvalidOperationException("Missing supported languages");
            }

            var disabledProducers = new List <int>();

            if (!string.IsNullOrEmpty(section.DisabledProducers))
            {
                var producerIds = section.DisabledProducers.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                disabledProducers = producerIds.Select(producerId => int.Parse(producerId.Trim())).ToList();
            }

            var mqHost = string.IsNullOrEmpty(section.Host)
                             ? EnvironmentManager.GetMqHost(sdkEnvironment)
                             : section.Host;
            var apiHost = string.IsNullOrEmpty(section.ApiHost)
                             ? EnvironmentManager.GetApiHost(sdkEnvironment)
                             : section.ApiHost;

            var config = new OddsFeedConfiguration(section.AccessToken,
                                                   sdkEnvironment,
                                                   defaultLanguage,
                                                   supportedLanguages,
                                                   mqHost,
                                                   section.VirtualHost,
                                                   EnvironmentManager.DefaultMqHostPort,
                                                   section.Username,
                                                   section.Password,
                                                   apiHost,
                                                   section.UseSSL,
                                                   section.UseApiSSL,
                                                   section.InactivitySeconds > 0 ? section.InactivitySeconds : SdkInfo.MinInactivitySeconds,
                                                   section.MaxRecoveryTime > 0 ? section.MaxRecoveryTime : SdkInfo.MaxRecoveryExecutionInSeconds,
                                                   section.MinIntervalBetweenRecoveryRequests > 0 ? section.MinIntervalBetweenRecoveryRequests : SdkInfo.DefaultIntervalBetweenRecoveryRequests,
                                                   section.NodeId,
                                                   disabledProducers,
                                                   section.ExceptionHandlingStrategy,
                                                   section.AdjustAfterAge,
                                                   section.HttpClientTimeout != SdkInfo.DefaultHttpClientTimeout ? section.HttpClientTimeout : SdkInfo.DefaultHttpClientTimeout,
                                                   section.RecoveryHttpClientTimeout != SdkInfo.DefaultHttpClientTimeout ? section.RecoveryHttpClientTimeout : SdkInfo.DefaultHttpClientTimeout,
                                                   section);

            return(config);
        }