예제 #1
0
파일: VkCity.cs 프로젝트: aw3s0me/W8VK
        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);
        }
예제 #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);
        }