public CountryMetadataProviderImpl(IServiceProvider serviceProvider, ILogger <CountryMetadataProviderImpl> logger) { _logger = logger; _countryProvider = new CountryProvider(); var countries = _countryProvider.GetCountries(); foreach (var country in countries) { var alpha2Code = country.Alpha2Code; var countryCode = Enum.GetName(typeof(Alpha2Code), alpha2Code).ToLower(); var countryNameEn = _countryProvider.GetCountryTranslatedName(alpha2Code, LanguageCode.EN); if (string.IsNullOrEmpty(countryNameEn)) { throw new Exception($"Country name for {alpha2Code} is missing (EN)"); } var countryNameDe = _countryProvider.GetCountryTranslatedName(alpha2Code, LanguageCode.DE); if (string.IsNullOrEmpty(countryNameDe)) { throw new Exception($"Country name for {alpha2Code} is missing (DE)"); } _localizedCountryNameMappings["en"].Add(new CountryCodeNameMapping() { CountryCode = countryCode, Name = countryNameEn }); _localizedCountryNameMappings["de"].Add(new CountryCodeNameMapping() { CountryCode = countryCode, Name = countryNameDe }); _validCountryCodes.Add(countryCode); } _localizedCountryNameMappings["en"].Sort((country1, country2) => { return(string.Compare(country1.Name, country2.Name)); }); _localizedCountryNameMappings["de"].Sort((country1, country2) => { return(string.Compare(country1.Name, country2.Name)); }); _geoIP2DatabaseReader = serviceProvider.GetRequiredService <IGeoIP2DatabaseReader>(); }
public MaxMind(IOptions <AppConfig> config) { _cityDb = new DatabaseReader(config.Value.MaxMindCityPath); _asnDb = new DatabaseReader(config.Value.MaxMindAsnPath); }
public ShortUrlLogger(IUrlRepository urlRepository, IGeoIP2DatabaseReader geoIp, Parser uaParser) { _urlRepository = urlRepository; _geoIp = geoIp; _uaParser = uaParser; }