Esempio n. 1
0
 public MemoryCacheStrategy(int cacheExpirationMinutes, IDataFileLoader dataFileLoader, IMemoryCache memoryCache) : this(memoryCache, new MemoryCacheEntryOptions())
 {
     _memoryCacheEntryOptions.AbsoluteExpirationRelativeToNow = new TimeSpan(hours: 0, minutes: cacheExpirationMinutes, seconds: 0);
     _dataFileLoader       = dataFileLoader;
     _postEvictionDelegate = new PostEvictionDelegate((key, value, reason, state) => {
         if (reason == EvictionReason.Expired)
         {
             _dataFileLoader.LoadFileAsync <T>(overwrite: true);
         }
     });
     _memoryCacheEntryOptions.RegisterPostEvictionCallback(_postEvictionDelegate);
 }
Esempio n. 2
0
        private async Task <List <T> > loadDataFileAsync <T>(Func <string, Task> progressHandlerAsync, bool downloadFilesFromWeb)
        {
            string dataFilePath  = Path.Combine(rootFilePath, "Data Files");
            string imageFilePath = Path.Combine(rootFilePath, "Images");

            IDataFileLoader loader = loaders.Single(l => l.LoaderType == typeof(T));

            List <T> items = await loader.LoadFromDataFileAsync <T>(dataFilePath, imageFilePath, downloadFilesFromWeb);

            if (progressHandlerAsync != null)
            {
                await progressHandlerAsync(loader.LoaderName);
            }

            return(items);
        }
 public AircraftRepository(IDataFileLoader loader, IMemoryCache memoryCache) : base(loader, memoryCache)
 {
 }
Esempio n. 4
0
 public RouteRepository(IDataFileLoader loader, IMemoryCache memoryCache) : base(loader, memoryCache)
 {
 }
Esempio n. 5
0
 public DataAccessFactory(HttpClient httpClient, IMemoryCache memoryCache)
 {
     _memoryCache    = memoryCache;
     _dataFileLoader = new DataFileLoader(httpClient);
     _dataFileLoader.LoadAllFilesAsync().Wait();
 }
Esempio n. 6
0
 public RepositoryBase(IDataFileLoader dataFileLoader, IMemoryCache memoryCache)
 {
     _cache          = new CacheBase <T>(new MemoryCacheStrategy <T>(OpenFligthsConstants.EXPIRY_MINUTES, dataFileLoader, memoryCache));
     _dataFileLoader = dataFileLoader;
 }