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)); }
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)); }
/// <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)); }