public static Status Create(dynamic root, User user = null) { if (root == null) throw new ArgumentNullException(); var status = new Status(); status.Id = (long)root["id"]; status.Text = root["text"]; status.User = user != null ? user : User.Create(root["user"]); status.CreatedAt = ((string)root["created_at"]).ToDateTime(); status.Source = ((string)root["source"]).ParseString(); status.InReplyToStatusId = root["in_reply_to_status_id"] == null ? 0 : (long)root["in_reply_to_status_id"]; status.InReplyToUserId = root["in_reply_to_user_id"] == null ? 0 : (long)root["in_reply_to_user_id"]; status.InReplyToUserScreenName = root["in_reply_to_screen_name"]; status.RetweetedOriginal = root.IsDefined("retweeted_status") ? Status.Create(root["retweeted_status"]) : null; status.RetweetedCount = (long)root["retweet_count"]; if (root.IsDefined("entities")) { var entities = root["entities"]; var urls = entities["urls"]; status.UrlEntities = new List<UrlEntity>(); foreach (var el in (dynamic[])urls) { status.UrlEntities.Add(UrlEntity.Create(el)); } var mentions = entities["user_mentions"]; status.UserMentionEntities = new List<UserMentionEntity>(); foreach (var el in (dynamic[])mentions) { status.UserMentionEntities.Add(UserMentionEntity.Create(el)); } var hashtags = entities["hashtags"]; status.HashtagEntities = new List<HashtagEntity>(); foreach (var el in (dynamic[])hashtags) { status.HashtagEntities.Add(HashtagEntity.Create(el)); } } return status; }
public static User Create(dynamic root) { if (root == null) throw new ArgumentNullException(); var user = new User(); user.Id = (long)root["id"]; user.UserName = ((string)root["name"]).ParseString(); user.ScreenName = root["screen_name"]; user.Bio = ((string)root["description"]).ParseString(); user.Followers = (long)root["followers_count"]; user.Followings = (long)root["friends_count"]; user.Favorites = (long)root["favourites_count"]; user.Listed = (long)root["listed_count"]; user.Tweets = (long)root["statuses_count"]; user.ProfileImage = root["profile_image_url"]; user.IsProtected = (bool)root["protected"]; user.CreatedAt = ((string)root["created_at"]).ToDateTime(); user.Location = root["location"]; user.LatestStatus = root.IsDefined("status") ? Status.Create(root["status"], user) : null; return user; }