public GeoTests() { var dataDirectory = PathHelper.ExpandPath(".\\"); var storage = new FolderFileStorage(dataDirectory); if (!storage.ExistsAsync(MindMaxGeoIPResolver.GEO_IP_DATABASE_PATH).Result) { var job = new DownloadGeoIPDatabaseJob(storage).Run(); Assert.NotNull(job); Assert.True(job.IsSuccess); } _resolver = new MindMaxGeoIPResolver(storage); }
private static async Task<IGeoIpService> GetResolverAsync(ILoggerFactory loggerFactory) { if (_service != null) return _service; var dataDirectory = PathHelper.ExpandPath(".\\"); var storage = new FolderFileStorage(dataDirectory); if (!await storage.ExistsAsync(MaxMindGeoIpService.GEO_IP_DATABASE_PATH)) { var job = new DownloadGeoIPDatabaseJob(new InMemoryCacheClient(), storage, loggerFactory); var result = await job.RunAsync(); Assert.NotNull(result); Assert.True(result.IsSuccess); } return _service = new MaxMindGeoIpService(storage, loggerFactory.CreateLogger<MaxMindGeoIpService>()); }
private async Task<IGeoIPResolver> GetResolverAsync() { if (_resolver != null) return _resolver; var dataDirectory = PathHelper.ExpandPath(".\\"); var storage = new FolderFileStorage(dataDirectory); if (!await storage.ExistsAsync(MindMaxGeoIPResolver.GEO_IP_DATABASE_PATH)) { var job = new DownloadGeoIPDatabaseJob(new InMemoryCacheClient(), storage); var result = await job.RunAsync(); Assert.NotNull(result); Assert.True(result.IsSuccess); } return _resolver = new MindMaxGeoIPResolver(storage); }