Ejemplo n.º 1
0
        /// <summary>
        /// Parses the given <paramref name="token"/> to a
        /// <see cref="LastUser"/>.
        /// </summary>
        /// <param name="token">JToken to parse.</param>
        /// <returns>Parsed LastUser.</returns>
        internal static LastUser ParseJToken(JToken token)
        {
            var u = new LastUser
            {
                Name           = token.Value <string>("name"),
                FullName       = token.Value <string>("realname"),
                Country        = token.Value <string>("country"),
                Id             = token.Value <string>("id"),
                Playcount      = token.Value <int>("playcount"),
                Playlists      = token.Value <int>("playlists"),
                Gender         = ParseGender(token.Value <string>("gender")),
                IsSubscriber   = Convert.ToBoolean(token.Value <int>("subscriber")),
                TimeRegistered = token.Value <double>("registered.unixtime").FromUnixTime().DateTime,
                Bootstrap      = token.Value <int>("bootstrap"),
                Type           = token.Value <string>("type")
            };

            var images = token.SelectToken("image");

            if (images != null)
            {
                u.Avatar = LastImageSet.ParseJToken(images);
            }

            return(u);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// TODO
        ///     "gender": "m",
        //"playcount": "79972",
        //"playlists": "4",
        //"bootstrap": "0",
        //"registered": {
        //  "#text": "2002-11-20 11:50",
        //  "unixtime": "1037793040"
        //},
        //"type": "alumni"
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        internal static LastUser ParseJToken(JToken token)
        {
            var u = new LastUser();

            u.Name     = token.Value <string>("name");
            u.FullName = token.Value <string>("realname");
            u.Country  = token.Value <string>("country");
            u.Id       = token.Value <string>("id");

            var subscribed = token.SelectToken("subscriber");

            if (subscribed != null)
            {
                u.IsSubscriber = Convert.ToBoolean(subscribed.Value <int>());
            }

            var images = token.SelectToken("image");

            if (images != null)
            {
                u.Avatar = LastImageSet.ParseJToken(images);
            }

            return(u);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// TODO 
        ///     "gender": "m",
        //"playcount": "79972",
        //"playlists": "4",
        //"bootstrap": "0",
        //"registered": {
        //  "#text": "2002-11-20 11:50",
        //  "unixtime": "1037793040"
        //},
        //"type": "alumni"
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        internal static LastUser ParseJToken(JToken token)
        {
            var u = new LastUser();

            u.Name = token.Value<string>("name");
            u.FullName = token.Value<string>("realname");
            u.Country = token.Value<string>("country");
            u.Id = token.Value<string>("id");

            var subscribed = token.SelectToken("subscriber");
            if (subscribed != null)
            {
                u.IsSubscriber = Convert.ToBoolean(subscribed.Value<int>());
            }

            var images = token.SelectToken("image");
            if (images != null)
            {
                u.Avatar = LastImageSet.ParseJToken(images);
            }

            return u;
        }