Пример #1
0
        public static string GetCountryInfo(string inputValue,
                                            CountryISO inputType,
                                            CountryISO outputType)
        {
            string    retValue  = string.Empty;
            TextAsset textAsset = (TextAsset)Resources.Load("Config/ISO_3166_1_Country_Code_List");
            string    xPath     = "ISO_3166_1/ISO_3166_1_Entry[" + inputType.ToString() + "='" + inputValue + "']/" + outputType.ToString();

            if (textAsset != null)
            {
                retValue = RetriveFromXML(textAsset.text.ToString(), xPath);
            }
            else
            {
                throw new System.Exception("Country List not found in Resources...");
            }
            return(retValue);
        }
Пример #2
0
        public static async Task <CountryISO> GetISO(string url)
        {
            CountryISO objData = new CountryISO();

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(url);
                    var result = await client.GetAsync(url);

                    var place = result.Content.ReadAsStringAsync().Result;
                    objData = JsonConvert.DeserializeObject <CountryISO>(await result.Content.ReadAsStringAsync());
                }
            }
            catch (Exception ex)
            {
            }
            return(objData);
        }