protected TwitterUser(JObject obj) : base(obj) { Id = obj.GetInt64("id"); IdStr = obj.GetString("id_str"); Name = obj.GetString("name"); ScreenName = obj.GetString("screen_name"); Location = obj.GetString("location"); Url = obj.GetString("url"); Description = obj.GetString("description"); IsProtected = obj.GetBoolean("protected"); FollowersCount = obj.GetInt32("followers_count"); FriendsCount = obj.GetInt32("friends_count"); ListedCount = obj.GetInt32("listed_count"); CreatedAt = TwitterUtils.ParseDateTime(obj.GetString("created_at")); FavouritesCount = obj.GetInt32("favourites_count"); UtcOffset = obj.HasValue("utc_offset") ? obj.GetInt32("utc_offset") : (int?)null; TimeZone = obj.GetString("time_zone"); IsGeoEnabled = obj.GetBoolean("geo_enabled"); IsVerified = obj.GetBoolean("verified"); StatusesCount = obj.GetInt32("statuses_count"); Language = obj.GetString("lang"); ContributorsEnabled = obj.GetBoolean("contributors_enabled"); IsTranslator = obj.GetBoolean("is_translator"); FollowRequestSent = obj.HasValue("follow_request_sent") && obj.GetBoolean("follow_request_sent"); Status = obj.GetObject("status", TwitterStatusMessage.Parse); Entities = obj.GetObject("entities", TwitterUserEntities.Parse); HasDefaultProfile = obj.GetBoolean("default_profile"); HasDefaultProfileImage = obj.GetBoolean("default_profile_image"); ProfileBackgroundColor = obj.GetString("profile_background_color"); ProfileBackgroundImageUrl = obj.GetString("profile_background_image_url"); ProfileBackgroundImageUrlHttps = obj.GetString("profile_background_image_url_https"); ProfileBackgroundTile = obj.GetBoolean("profile_background_tile"); ProfileBannerUrl = obj.GetString("profile_banner_url"); ProfileImageUrl = obj.GetString("profile_image_url"); ProfileImageUrlHttps = obj.GetString("profile_image_url_https"); ProfileLinkColor = obj.GetString("profile_link_color"); ProfileSidebarBorderColor = obj.GetString("profile_sidebar_border_color"); ProfileSidebarFillColor = obj.GetString("profile_sidebar_fill_color"); ProfileTextColor = obj.GetString("profile_text_color"); ProfileUseBackgroundImage = obj.GetBoolean("profile_use_background_image"); }
/// <summary> /// Gets a user from the specified <var>JsonObject</var>. /// </summary> /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param> public static TwitterUser Parse(JsonObject obj) { // Error checking if (obj == null) { return(null); } if (obj.HasValue("error")) { throw TwitterException.Parse(obj.GetArray("error")); } TwitterUser user = new TwitterUser(obj); #region Basic properties user.Id = obj.GetInt64("id"); user.IdStr = obj.GetString("id_str"); user.Name = obj.GetString("name"); user.ScreenName = obj.GetString("screen_name"); user.Location = obj.GetString("location"); user.Url = obj.GetString("url"); user.Description = obj.GetString("description"); user.IsProtected = obj.GetBoolean("protected"); user.FollowersCount = obj.GetInt32("followers_count"); user.FriendsCount = obj.GetInt32("friends_count"); user.ListedCount = obj.GetInt32("listed_count"); user.CreatedAt = TwitterUtils.ParseDateTime(obj.GetString("created_at")); user.FavouritesCount = obj.GetInt32("favourites_count"); if (obj.HasValue("utc_offset")) { user.UtcOffset = obj.GetInt32("utc_offset"); } user.TimeZone = obj.GetString("time_zone"); user.IsGeoEnabled = obj.GetBoolean("geo_enabled"); user.IsVerified = obj.GetBoolean("verified"); user.StatusesCount = obj.GetInt32("statuses_count"); user.Language = obj.GetString("lang"); user.ContributorsEnabled = obj.GetBoolean("contributors_enabled"); user.IsTranslator = obj.GetBoolean("is_translator"); user.FollowRequestSent = obj.HasValue("follow_request_sent") && obj.GetBoolean("follow_request_sent"); user.Status = obj.GetObject("status", TwitterStatusMessage.Parse); user.Entities = obj.GetObject("entities", TwitterUserEntities.Parse); #endregion #region Profile properties user.HasDefaultProfile = obj.GetBoolean("default_profile"); user.HasDefaultProfileImage = obj.GetBoolean("default_profile_image"); user.ProfileBackgroundColor = obj.GetString("profile_background_color"); user.ProfileBackgroundImageUrl = obj.GetString("profile_background_image_url"); user.ProfileBackgroundImageUrlHttps = obj.GetString("profile_background_image_url_https"); user.ProfileBackgroundTile = obj.GetBoolean("profile_background_tile"); user.ProfileBannerUrl = obj.GetString("profile_banner_url"); user.ProfileImageUrl = obj.GetString("profile_image_url"); user.ProfileImageUrlHttps = obj.GetString("profile_image_url_https"); user.ProfileLinkColor = obj.GetString("profile_link_color"); user.ProfileSidebarBorderColor = obj.GetString("profile_sidebar_border_color"); user.ProfileSidebarFillColor = obj.GetString("profile_sidebar_fill_color"); user.ProfileTextColor = obj.GetString("profile_text_color"); user.ProfileUseBackgroundImage = obj.GetBoolean("profile_use_background_image"); #endregion return(user); }