internal static VkCatalogBlock FromJson(JToken json) { if (json == null) { throw new ArgumentException("Json can not be null."); } var result = new VkCatalogBlock(); result.Id = json["id"].Value <string>(); result.Title = json["title"].Value <string>(); result.Subtitle = json["subtitle"].Value <string>(); result.Type = json["type"].Value <string>(); result.Count = json["count"].Value <int>(); result.Source = json["source"].Value <string>(); if (json["audios"] != null) { result.Audios = json["audios"].Select(VkAudio.FromJson).ToList(); } if (json["thumbs"] != null) { result.Thumbs = json["thumbs"].ToObject <List <VkThumb> >(); } if (json["owners"] != null) { result.Owners = json["owners"].Select(x => { if (x["type"].Value <string>() != "profile") { return((VkProfileBase)VkGroup.FromJson(x)); } else { return((VkProfileBase)VkProfile.FromJson(x)); } }).ToList(); } if (json["playlists"] != null) { result.Playlists = json["playlists"].Select(VkPlaylist.FromJson).ToList(); } if (json["extended_playlists"] != null) { result.ExtendedPlaylists = json["extended_playlists"].Select(VkExtendedPlaylist.FromJson).ToList(); } return(result); }
public async Task <VkCatalogBlock> GetCatalogBlockById(VkCatalogBlockType block) { var parameters = new Dictionary <string, string>(); parameters.Add("block_id", ((int)block).ToString()); _vkontakte.SignMethod(parameters); var response = await VkRequest.GetAsync(VkConst.MethodBase + "audio.getCatalogBlockById", parameters); if (response.SelectToken("response.block") != null) { return(VkCatalogBlock.FromJson(response.SelectToken("response.block"))); } return(null); }