public static List<CommentTimelineList> Parse(XElement element) { List<CommentTimelineList> commentcollection = new List<CommentTimelineList>(); foreach (XElement commentnode in element.Elements()) { CommentTimelineList comments = new CommentTimelineList(); comments.CreatedTime = ParseDateTime(GetElementValue(commentnode, "created_at")); comments.CommentID = GetElementValue(commentnode, "id"); comments.CommentContent = GetElementValue(commentnode, "text"); UserList useritem = new UserList(); useritem.UserID = GetElementValue(commentnode.Element("user"), "id"); useritem.TwitterName = GetElementValue(commentnode.Element("user"), "screen_name"); useritem.FriendName = GetElementValue(commentnode.Element("user"), "name"); useritem.Province = GetElementValue(commentnode.Element("user"), "province"); useritem.City = GetElementValue(commentnode.Element("user"), "city"); useritem.Location = GetElementValue(commentnode.Element("user"), "location"); useritem.Description = GetElementValue(commentnode.Element("user"), "description"); useritem.BlogURL = GetElementValue(commentnode.Element("user"), "url"); useritem.CustomizeImageURL = GetElementValue(commentnode.Element("user"), "profile_image_url"); useritem.Domain = GetElementValue(commentnode.Element("user"), "domain"); useritem.Gender = GetElementValue(commentnode.Element("user"), "gender"); useritem.FollowerCount = Convert.ToInt32(GetElementValue(commentnode.Element("user"), "followers_count")); useritem.FriendCount = Convert.ToInt32(GetElementValue(commentnode.Element("user"), "friends_count")); useritem.StatusesCount = Convert.ToInt32(GetElementValue(commentnode.Element("user"), "statuses_count")); useritem.FavouriteCount = Convert.ToInt32(GetElementValue(commentnode.Element("user"), "favourites_count")); useritem.CreateTime = GetElementValue(commentnode.Element("user"), "created_at"); useritem.IsFollowing = Convert.ToBoolean(GetElementValue(commentnode.Element("user"), "following")); useritem.IsVerified = Convert.ToBoolean(GetElementValue(commentnode.Element("user"), "verified")); useritem.IsEnableGeo = Convert.ToBoolean(GetElementValue(commentnode.Element("user"), "geo_enabled")); comments.UsersItem = useritem; StatusList statusitem = new StatusList(); statusitem.TwitterID = GetElementValue(commentnode.Element("status"), "id"); comments.StatusItem = statusitem; commentcollection.Add(comments); } return commentcollection; }
public static List<FollowerList> Parse(XElement element) { List<FollowerList> followercollection = new List<FollowerList>(); List<UserList> usercollection = new List<UserList>(); FollowerList followeritem = new FollowerList(); foreach (XElement followernode in element.Elements()) { UserList useritem = new UserList(); useritem.UserID = GetElementValue(followernode, "id"); useritem.TwitterName = GetElementValue(followernode, "screen_name"); useritem.FriendName = GetElementValue(followernode, "name"); useritem.Province = GetElementValue(followernode, "province"); useritem.City = GetElementValue(followernode, "city"); useritem.Location = GetElementValue(followernode, "location"); useritem.Description = GetElementValue(followernode, "description"); useritem.BlogURL = GetElementValue(followernode, "url"); useritem.CustomizeImageURL = GetElementValue(followernode, "profile_image_url"); useritem.Domain = GetElementValue(followernode, "domain"); useritem.Gender = GetElementValue(followernode, "gender"); useritem.FollowerCount = Convert.ToInt32(GetElementValue(followernode, "followers_count")); useritem.FriendCount = Convert.ToInt32(GetElementValue(followernode, "friends_count")); useritem.StatusesCount = Convert.ToInt32(GetElementValue(followernode, "statuses_count")); useritem.FavouriteCount = Convert.ToInt32(GetElementValue(followernode, "favourites_count")); useritem.CreateTime = GetElementValue(followernode, "created_at"); useritem.IsFollowing = Convert.ToBoolean(GetElementValue(followernode, "following")); useritem.IsVerified = Convert.ToBoolean(GetElementValue(followernode, "verified")); useritem.IsEnableGeo = Convert.ToBoolean(GetElementValue(followernode, "geo_enabled")); StatusList statusitem = new StatusList(); foreach (XElement subelement in followernode.Descendants("status")) { statusitem.CreateTime = subelement.Element(XName.Get("created_at")).Value; statusitem.TwitterID = subelement.Element(XName.Get("id")).Value; statusitem.TwitterContent = subelement.Element(XName.Get("text")).Value; statusitem.Source = subelement.Element(XName.Get("source")).Value; statusitem.IsFavorited = Convert.ToBoolean(subelement.Element(XName.Get("favorited")).Value); statusitem.IsTruncated = Convert.ToBoolean(subelement.Element(XName.Get("truncated")).Value); statusitem.GeoRSS = subelement.Element(XName.Get("geo")).Value; statusitem.ReplyStatusID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_status_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_status_id")).Value); statusitem.ReplyUserID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_user_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_user_id")).Value); statusitem.ReplyTwitterName = subelement.Element(XName.Get("in_reply_to_screen_name")).Value; if (subelement.XPathSelectElement("thumbnail_pic") != null) statusitem.ThumbnailImageURL = subelement.Element(XName.Get("thumbnail_pic")).Value; if (subelement.XPathSelectElement("bmiddle_pic") != null) statusitem.MiddleImageURL = subelement.Element(XName.Get("bmiddle_pic")).Value; if (subelement.XPathSelectElement("original_pic") != null) statusitem.OriginalImageURL = subelement.Element(XName.Get("original_pic")).Value; } useritem.StatusItems = statusitem; usercollection.Add(useritem); } followeritem.Users = usercollection; followeritem.NextCursor = GetElementValue(element, "next_cursor"); followeritem.PreviewCursor = GetElementValue(element, "previous_cursor"); followercollection.Add(followeritem); return followercollection; }
public static UserList Parse(XElement element) { UserList users = new UserList(); users.UserID = GetElementValue(element, "id"); users.TwitterName = GetElementValue(element, "screen_name"); users.FriendName = GetElementValue(element, "name"); users.Province = GetElementValue(element, "province"); users.City = GetElementValue(element, "city"); users.Location = GetElementValue(element, "location"); users.Description = GetElementValue(element, "description"); users.BlogURL = GetElementValue(element, "url"); users.CustomizeImageURL = GetElementValue(element, "profile_image_url"); users.Domain = GetElementValue(element, "domain"); users.Gender = GetElementValue(element, "gender"); users.FollowerCount = Convert.ToInt32(GetElementValue(element, "followers_count")); users.FriendCount = Convert.ToInt32(GetElementValue(element, "friends_count")); users.StatusesCount = Convert.ToInt32(GetElementValue(element, "statuses_count")); users.FavouriteCount = Convert.ToInt32(GetElementValue(element, "favourites_count")); users.CreateTime = GetElementValue(element, "created_at"); users.IsFollowing = Convert.ToBoolean(GetElementValue(element, "following")); users.IsVerified = Convert.ToBoolean(GetElementValue(element, "verified")); users.IsEnableGeo = Convert.ToBoolean(GetElementValue(element, "geo_enabled")); var tmp = (from status in element.Descendants("user") select status.Element("name").Value); foreach (var p in tmp) { string a = p.ToString(); } StatusList statusitem = new StatusList(); foreach (XElement subelement in element.Descendants("status")) { statusitem.CreateTime = subelement.Element(XName.Get("created_at")).Value; statusitem.TwitterID = subelement.Element(XName.Get("id")).Value; statusitem.TwitterContent = subelement.Element(XName.Get("text")).Value; statusitem.Source = subelement.Element(XName.Get("source")).Value; statusitem.IsFavorited = Convert.ToBoolean(subelement.Element(XName.Get("favorited")).Value); statusitem.IsTruncated = Convert.ToBoolean(subelement.Element(XName.Get("truncated")).Value); statusitem.GeoRSS = subelement.Element(XName.Get("geo")).Value; statusitem.ReplyStatusID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_status_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_status_id")).Value); statusitem.ReplyUserID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_user_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_user_id")).Value); statusitem.ReplyTwitterName = subelement.Element(XName.Get("in_reply_to_screen_name")).Value; if (subelement.XPathSelectElement("thumbnail_pic") != null) statusitem.ThumbnailImageURL = subelement.Element(XName.Get("thumbnail_pic")).Value; if (subelement.XPathSelectElement("bmiddle_pic") != null) statusitem.MiddleImageURL = subelement.Element(XName.Get("bmiddle_pic")).Value; if (subelement.XPathSelectElement("original_pic") != null) statusitem.OriginalImageURL = subelement.Element(XName.Get("original_pic")).Value; } users.StatusItems = statusitem; return users; }