예제 #1
0
파일: App.xaml.cs 프로젝트: DL444/ucqu-ng
        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> >();
        }
예제 #2
0
        public void StaticCacheHandler_GetValueWithArea_NoExistingItems()
        {
            ICacheService handler = new LocalCacheService();
            object        value   = handler.GetCacheValue("LocalCacheService_GetValueWithRegion_NoExistingItems", "area1");

            Assert.Null(value);
        }
예제 #3
0
        public void StaticCacheHandler_Get_None()
        {
            ICacheService handler = new LocalCacheService();

            object value = handler.GetCacheValue("key", "area");

            Assert.Null(value);
        }
예제 #4
0
        public void StaticCacheHandler_Get_Found()
        {
            ICacheService handler = new LocalCacheService();

            handler.PutCacheValue("key", "val1", "area");

            object value = handler.GetCacheValue("key", "area");

            Assert.Equal("val1", value);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public void StaticCacheHandler_GetWithDifferentType_Found()
        {
            ICacheService handler = new LocalCacheService();

            handler.PutCacheValue("key", "val1", "area");

            AuthorityReport site = handler.GetCacheValue <AuthorityReport>("key", "area");

            Assert.Null(site);
        }
예제 #7
0
        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);
        }
예제 #8
0
        protected async Task <string> GetBaseUrlAsync()
        {
            var baseUrl = await LocalCacheService.GetObjectAsync <string>(CacheConst.BaseUrl);

            if (baseUrl == null)
            {
                return(null);
            }
            MemService.BaseUrl = baseUrl;
            return(baseUrl);
        }
예제 #9
0
        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);
        }
예제 #10
0
 /// <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);
        }
예제 #12
0
        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();
        }
예제 #13
0
        public void StaticCacheHandler_PutValueWithArea_NoExisting()
        {
            ICacheService handler = new LocalCacheService();

            handler.PutCacheValue("LocalCacheService_PutValueWithRegion_NoExisting", "value1", "area1");
        }
예제 #14
0
        public static async Task <List <ItemWithPrice> > GetCachedSentItemsToMarket(this LocalCacheService cacheService)
        {
            var set = await cacheService.GetValuesFromSet <ItemWithPrice>(CacheKeyHelper.SentItemsToMarketCacheKey);

            return(set.ToList());
        }
예제 #15
0
 public EnumsController(TenantRepository <T, TDbContext> repo, ApplicationContext appContext, LocalCacheService cache)
 {
     _repo       = repo;
     _appContext = appContext;
     _cache      = cache;
 }
예제 #16
0
        protected async Task SaveBaseUrlAsync(string baseUrl)
        {
            await LocalCacheService.UpdateObjectAsync(CacheConst.BaseUrl, baseUrl);

            MemService.BaseUrl = baseUrl;
        }
예제 #17
0
        public void StaticCacheHandler_Ctor()
        {
            ICacheService handler = new LocalCacheService();

            Assert.NotNull(handler);
        }
예제 #18
0
 public static async Task RemoveSentItemToMarketFromCacheAsync(this LocalCacheService cacheService, InventoryItem item, uint price)
 {
     var cacheModel = new ItemWithPrice(item, price);
     await cacheService.RemoveFromSetAsync(CacheKeyHelper.SentItemsToMarketCacheKey, cacheModel);
 }