Example #1
0
 /// <summary>
 /// Attempts to construct the <see cref="SdkConfigurationSection"/> from the app.config file
 /// </summary>
 /// <param name="section">When the call returns in points to the created <see cref="SdkConfigurationSection"/></param>
 /// <returns>True if the <see cref="SdkConfigurationSection"/> was successfully constructed; False otherwise</returns>
 public static bool TryGetSection(out ISdkConfigurationSection section)
 {
     section = null;
     try
     {
         section = GetSection();
         return(true);
     }
     catch (Exception ex)
     {
         if (ex is InvalidOperationException || ex is ConfigurationErrorsException)
         {
             return(false);
         }
         throw;
     }
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SdkConfiguration"/> class
        /// </summary>
        /// <param name="section">A <see cref="SdkConfigurationSection"/> instance containing config values</param>
        public SdkConfiguration(ISdkConfigurationSection section)
        {
            Guard.Argument(section, nameof(section)).NotNull();

            Username    = section.Username;
            Password    = section.Password;
            Host        = section.Host;
            VirtualHost = string.IsNullOrEmpty(section.VirtualHost)
                ? "/" + Username
                : section.VirtualHost.StartsWith("/")
                    ? section.VirtualHost
                    : "/" + section.VirtualHost;
            UseSsl        = section.UseSsl;
            SslServerName = section.SslServerName;
            NodeId        = section.NodeId;
            BookmakerId   = section.BookmakerId;
            LimitId       = section.LimitId;
            Currency      = section.Currency;
            Channel       = section.Channel;

            StatisticsEnabled                 = section.StatisticsEnabled;
            StatisticsRecordLimit             = section.StatisticsRecordLimit;
            StatisticsTimeout                 = section.StatisticsTimeout;
            AccessToken                       = section.AccessToken;
            UfEnvironment                     = section.UfEnvironment;
            ProvideAdditionalMarketSpecifiers = section.ProvideAdditionalMarketSpecifiers;
            Port = UseSsl ? 5671 : 5672;
            if (section.Port > 0)
            {
                Port = section.Port;
            }
            ExclusiveConsumer = section.ExclusiveConsumer;

            if (Host.Contains(":"))
            {
                throw new ArgumentException("Host can not contain port number. Only domain name or ip address. E.g. mtsgate-ci.betradar.com");
            }

            KeycloakHost     = section.KeycloakHost;
            KeycloakUsername = section.KeycloakUsername;
            KeycloakPassword = section.KeycloakPassword;
            KeycloakSecret   = section.KeycloakSecret;
            MtsClientApiHost = section.MtsClientApiHost;

            if (MtsClientApiHost != null)
            {
                if (KeycloakHost == null)
                {
                    throw new ArgumentException("KeycloakHost must be set.");
                }
                if (KeycloakSecret == null)
                {
                    throw new ArgumentException("KeycloakSecret must be set.");
                }
            }

            TicketResponseTimeoutLive         = section.TicketResponseTimeoutLive;
            TicketResponseTimeoutPrematch     = section.TicketResponseTimeoutPrematch;
            TicketCancellationResponseTimeout = section.TicketCancellationResponseTimeout;
            TicketCashoutResponseTimeout      = section.TicketCashoutResponseTimeout;
            TicketNonSrSettleResponseTimeout  = section.TicketNonSrSettleResponseTimeout;

            ObjectInvariant();
        }