Exemplo n.º 1
0
 public void Malaysia()
 {
     foreach (var ipAddress in _malaysianIpAddresses)
     {
         Assert.AreEqual(Country.Malaysia, _geoLocationInfoProvider.GetCountry(ipAddress).Country);
     }
 }
Exemplo n.º 2
0
        private static ILocalizationInfo GetNewLocalizationInfo()
        {
            //var tmp = new CountryInfo()
            //{
            //    Country = Country.Malaysia,
            //    CountryIsoCode = "MY"
            //};
            //return new TeeyootLocalizationInfo(tmp);

            var         ipAddress = _ipAddressProvider.GetIpAddress();
            CountryInfo country   = null;

            try
            {
                //WebClient web = new WebClient();
                //var address = string.Format("http://freegeoip.net/{0}/{1}", "json", ipAddress);
                //string retVal = web.DownloadString(address);

                var ipAddressLocation = IpToCountry.IpToCountryCache.GetIpAddressLocation(IPAddress.Parse(ipAddress));
                //var isoCode = (string)Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(retVal).country_code;

                country = GetCurrentCountryFrom(ipAddressLocation.CountryCode);
            }
            catch (Exception ex)
            {
                country = _geoLocationInfoProvider.GetCountry(ipAddress);
            }

            return(new TeeyootLocalizationInfo(country));
        }