private static void ConfigureServices(IServiceCollection services, IConfiguration config) { services.AddSingleton <ICredentialService>(new UserCredentialService()); services.AddTransient <IWindowsHelloService, WindowsHelloService>(); var baseAddress = new Uri(config.GetValue <string>("Backend:BaseAddress")); int retryCount = config.GetValue("Backend:RetryCount", 2); int timeout = config.GetValue("Backend:Timeout", 30); services.AddHttpClientWithDefaultPolicy <IDataService, BackendService>(baseAddress, retryCount, timeout); services.AddHttpClientWithDefaultPolicy <ISignInService, BackendService>(baseAddress, retryCount, timeout); services.AddHttpClientWithDefaultPolicy <ICalendarSubscriptionService, BackendService>(baseAddress, retryCount, timeout); services.AddHttpClientWithDefaultPolicy <INotificationChannelService, BackendService>(baseAddress, retryCount, timeout); services.AddHttpClientWithDefaultPolicy <IRemoteSettingsService, BackendService>(baseAddress, retryCount, timeout); LocalCacheService localCacheService = new LocalCacheService(config); services.AddSingleton <IDataService>(localCacheService); services.AddSingleton <ILocalCacheService>(localCacheService); services.AddSingleton <ILocalizationService, ResourceLocalizationService>(); services.AddTransient <ILocalSettingsService, LocalSettingsService>(); services.AddTransient <INotificationService, NotificationService>(); services.AddMessageHub <SignInMessage, EventMessageService <SignInMessage> >(); services.AddMessageHub <DaySelectedMessage, EventMessageService <DaySelectedMessage> >(); }
public void StaticCacheHandler_GetValueWithArea_NoExistingItems() { ICacheService handler = new LocalCacheService(); object value = handler.GetCacheValue("LocalCacheService_GetValueWithRegion_NoExistingItems", "area1"); Assert.Null(value); }
public void StaticCacheHandler_Get_None() { ICacheService handler = new LocalCacheService(); object value = handler.GetCacheValue("key", "area"); Assert.Null(value); }
public void StaticCacheHandler_Get_Found() { ICacheService handler = new LocalCacheService(); handler.PutCacheValue("key", "val1", "area"); object value = handler.GetCacheValue("key", "area"); Assert.Equal("val1", value); }
public void StaticCacheHandler_GetWithType_Found() { ICacheService handler = new LocalCacheService(); handler.PutCacheValue("key", "val1", "area"); string value = handler.GetCacheValue <string>("key", "area"); Assert.Equal("val1", value); }
public void StaticCacheHandler_GetWithDifferentType_Found() { ICacheService handler = new LocalCacheService(); handler.PutCacheValue("key", "val1", "area"); AuthorityReport site = handler.GetCacheValue <AuthorityReport>("key", "area"); Assert.Null(site); }
public void StaticCacheHandler_RetrieveStoredItem() { ICacheService handler = new LocalCacheService(); handler.PutCacheValue("LocalCacheService_RetrieveStoredItem", "value1", "area1"); object value = handler.GetCacheValue("LocalCacheService_RetrieveStoredItem", "area1"); Assert.NotNull(value); Assert.Equal("value1", value); }
protected async Task <string> GetBaseUrlAsync() { var baseUrl = await LocalCacheService.GetObjectAsync <string>(CacheConst.BaseUrl); if (baseUrl == null) { return(null); } MemService.BaseUrl = baseUrl; return(baseUrl); }
public void StaticCacheHandler_RemoveCacheValue() { ICacheService handler = new LocalCacheService(); handler.PutCacheValue("key", "val1", "area"); handler.RemoveCacheValue("key", "area"); object value = handler.GetCacheValue("key", "area"); Assert.Null(value); }
/// <inheritdoc /> public TestInProcessServiceClientCache( ILogger logger, IAbsFileSystem fileSystem, Func <AbsolutePath, ICache> contentStoreFactory, LocalServerConfiguration contentServerConfiguration, ServiceClientContentStoreConfiguration clientConfiguration) { // Initialize with fewer threads for tests GrpcEnvironment.InitializeIfNeeded(3); _server = new LocalCacheService(logger, fileSystem, clientConfiguration.Scenario, contentStoreFactory, contentServerConfiguration); _client = new ServiceClientCache(logger, fileSystem, clientConfiguration); SetThreadPoolSizes(); }
public CheckMarketPriceJob( ILogger <CheckMarketPriceJob> logger, LocalCacheService cacheService, MarketService marketService, DelayedExecutionPool delayedExecutionPool, JobManager jobManager) : base(logger, jobManager) { _logger = logger; _cacheService = cacheService; _marketService = marketService; _delayedExecutionPool = delayedExecutionPool; JobExecuteDelay = TimeSpan.FromMinutes(15); }
private void LoadNewData() { DateTime timestamp = DateTime.MinValue; int page = 1; Task t = new Task(async() => { timestamp = await LocalCacheService.GetCacheTimestamp(_name); if (!_hasLoaded) { string data = await LocalCacheService.ReadCacheData(this._name); if (data != null && data.Length > 5) { var items = await HydrateItems(data); MergeInItems(items); } } if (DateTime.Now - timestamp > new TimeSpan(0, 5, 0)) { string data = await FetchData(page, _pageSize); var items = await HydrateItems(data); if (items != null && items.Count > 1) { LocalCacheService.PersistCacheData(data, this._name); } MergeInItems(items); } _hasLoaded = true; HasData = true; OnDataLoaded(); }); t.Start(); }
public void StaticCacheHandler_PutValueWithArea_NoExisting() { ICacheService handler = new LocalCacheService(); handler.PutCacheValue("LocalCacheService_PutValueWithRegion_NoExisting", "value1", "area1"); }
public static async Task <List <ItemWithPrice> > GetCachedSentItemsToMarket(this LocalCacheService cacheService) { var set = await cacheService.GetValuesFromSet <ItemWithPrice>(CacheKeyHelper.SentItemsToMarketCacheKey); return(set.ToList()); }
public EnumsController(TenantRepository <T, TDbContext> repo, ApplicationContext appContext, LocalCacheService cache) { _repo = repo; _appContext = appContext; _cache = cache; }
protected async Task SaveBaseUrlAsync(string baseUrl) { await LocalCacheService.UpdateObjectAsync(CacheConst.BaseUrl, baseUrl); MemService.BaseUrl = baseUrl; }
public void StaticCacheHandler_Ctor() { ICacheService handler = new LocalCacheService(); Assert.NotNull(handler); }
public static async Task RemoveSentItemToMarketFromCacheAsync(this LocalCacheService cacheService, InventoryItem item, uint price) { var cacheModel = new ItemWithPrice(item, price); await cacheService.RemoveFromSetAsync(CacheKeyHelper.SentItemsToMarketCacheKey, cacheModel); }