Esempio n. 1
0
        internal static VkPlaylist FromJson(JToken json)
        {
            if (json == null)
            {
                throw new ArgumentException("Json can not be null.");
            }

            var result = new VkPlaylist();

            result.Id          = json["id"].Value <long>();
            result.OwnerId     = json["owner_id"].Value <long>();
            result.Type        = json["type"].Value <int>();
            result.Title       = json["title"].Value <string>();
            result.Description = json["description"].Value <string>();

            result.Genres = json["genres"].ToObject <List <VkPlaylistGenre> >();
            if (json["main_artists"] != null)
            {
                result.Artists = json["main_artists"].ToObject <List <VkArtist> >();
            }

            result.Count = json["count"].Value <int>();

            result.Followers = json["followers"].Value <long>();
            result.Plays     = json["plays"].Value <long>();

            result.CreateTime = DateTimeExtensions.UnixTimeStampToDateTime(json["create_time"].Value <long>());
            result.UpdateTime = DateTimeExtensions.UnixTimeStampToDateTime(json["update_time"].Value <long>());

            if (json["original"] != null)
            {
                result.Original = json["original"].ToObject <VkPlaylistOriginal>();
            }

            if (json["photo"] != null)
            {
                result.Photo = json["photo"].ToObject <VkThumb>();
            }

            if (json["thumbs"] != null)
            {
                result.Thumbs = json["thumbs"].ToObject <List <VkThumb> >();
            }

            if (json["access_key"] != null)
            {
                result.AccessKey = json["access_key"].Value <string>();
            }

            return(result);
        }
Esempio n. 2
0
        internal static VkExtendedPlaylist FromJson(JToken json)
        {
            if (json == null)
            {
                throw new ArgumentException("Json can not be null.");
            }

            var result = new VkExtendedPlaylist();

            result.Title = json["title"].Value <string>();
            if (json["subtitle"] != null)
            {
                result.Subtitle = json["subtitle"].Value <string>();
            }

            result.Playlist = VkPlaylist.FromJson(json["playlist"]);

            return(result);
        }