Beispiel #1
0
        public static VkCity FromJson(JToken json)
        {
            var vkCity = new VkCity();

            vkCity.Cid = json["cid"].Value <long>();

            if (json["name"] != null)
            {
                vkCity.Name = json["name"].Value <string>();
            }

            return(vkCity);
        }
Beispiel #2
0
        public async Task <IEnumerable <VkCity> > Get(IEnumerable <string> cids)
        {
            var dictionary = new Dictionary <string, string>();

            if (cids != null)
            {
                dictionary.Add("cids", string.Join(",", cids));
            }
            JObject jObject = await new VkRequest(new Uri("https://api.vk.com/method/places.getCityById"), dictionary, "GET").Execute();

            VkErrorProcessor.ProcessError(jObject);
            IEnumerable <VkCity> result;

            if (jObject["response"].HasValues)
            {
                result = Enumerable.Select <JToken, VkCity>(jObject["response"], (JToken u) => VkCity.FromJson(u));
            }
            else
            {
                result = null;
            }
            return(result);
        }