コード例 #1
0
        public static ISelectionBuilder Create()
        {
            //TODO: prone to fail in web app
            var configInternal = new SdkConfigurationInternal(new SdkConfiguration(SdkConfigurationSection.GetSection()), null);
            var value          = new Random((int)DateTime.Now.Ticks).Next();
            var dataFetcher    = new LogHttpDataFetcher(new HttpClient(),
                                                        configInternal.AccessToken,
                                                        new IncrementalSequenceGenerator(value, long.MaxValue),
                                                        3,
                                                        12);
            var deserializer = new Deserializer <market_descriptions>();
            var mapper       = new MarketDescriptionsMapperFactory();

            var dataProvider = new DataProvider <market_descriptions, IEnumerable <MarketDescriptionDTO> >(
                configInternal.ApiHost + "/v1/descriptions/{0}/markets.xml?include_mappings=true",
                dataFetcher,
                dataFetcher,
                deserializer,
                mapper);

            var marketDescriptionCache = new MarketDescriptionCache(new MemoryCache("InvariantMarketDescriptionCache"),
                                                                    dataProvider,
                                                                    new [] { new CultureInfo("en") },
                                                                    configInternal.AccessToken,
                                                                    TimeSpan.FromHours(4),
                                                                    new CacheItemPolicy {
                SlidingExpiration = TimeSpan.FromDays(1)
            });
            var marketDescriptionProvider = new MarketDescriptionProvider(marketDescriptionCache, new[] { new CultureInfo("en") });

            return(new SelectionBuilder(marketDescriptionProvider, configInternal, false));
        }
コード例 #2
0
        private static ISdkConfiguration ToSdkConfiguration(this XmlReader reader)
        {
            var config       = new SdkConfigurationSection();
            var deserializer = config.GetType().GetMethod("DeserializeSection",
                                                          BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, new[] { typeof(XmlReader) },
                                                          null);

            deserializer?.Invoke(config, new object[] { reader });
            return(new SdkConfiguration(config));
        }
コード例 #3
0
ファイル: SenderBuilder.cs プロジェクト: sportradar/MtsSdkNet
        public static ISenderBuilder Create(int bookmakerId       = 0,
                                            int limitId           = 0,
                                            string currency       = null,
                                            SenderChannel?channel = null)
        {
            var tempChannel = SenderChannel.Internet;

            try
            {
                if (!_sectionLoaded)
                {
                    SdkConfigurationSection.TryGetSection(out _section);
                    _sectionLoaded = true;
                }

                if (_section != null)
                {
                    if (bookmakerId == 0)
                    {
                        bookmakerId = _section.BookmakerId;
                    }
                    if (limitId == 0)
                    {
                        limitId = _section.LimitId;
                    }
                    if (string.IsNullOrEmpty(currency))
                    {
                        currency = _section.Currency;
                    }
                    if (_section.Channel != null)
                    {
                        tempChannel = (SenderChannel)_section.Channel;
                    }
                }
                if (channel != null)
                {
                    tempChannel = (SenderChannel)channel;
                }
            }
            catch (Exception)
            {
                // ignored
            }
            return(new SenderBuilder(bookmakerId, limitId, currency, tempChannel));
        }
コード例 #4
0
        public static ITicketCashoutBuilder Create(int bookmakerId = 0)
        {
            if (!_sectionLoaded)
            {
                SdkConfigurationSection.TryGetSection(out _section);
                _sectionLoaded = true;
            }

            if (_section != null && bookmakerId == 0)
            {
                try
                {
                    var config = SdkConfigurationSection.GetSection();
                    bookmakerId = config.BookmakerId;
                }
                catch (Exception)
                {
                    // if exists, try to load, otherwise user must explicitly set it
                }
            }
            return(new TicketCashoutBuilder(bookmakerId));
        }
コード例 #5
0
        /// <summary>
        /// Constructs a <see cref="ISdkConfiguration" /> instance with information read from application configuration file
        /// </summary>
        /// <returns>A <see cref="ISdkConfiguration" /> instance read from application configuration file</returns>
        /// <exception cref="InvalidOperationException">The configuration could not be loaded, or the requested section does not exist in the config file</exception>
        /// <exception cref="ConfigurationErrorsException">The section read from the configuration file is not valid</exception>
        public static ISdkConfiguration GetConfiguration()
        {
            var section = SdkConfigurationSection.GetSection();

            return(new SdkConfiguration(section));
        }