Ejemplo n.º 1
0
        public static List<FriendTimelineList> Parse(XElement element)
        {
            List<FriendTimelineList> friendtimecollection = new List<FriendTimelineList>();

            foreach (XElement friendtimelinenode in element.Elements())
            {
                FriendTimelineList friendtimelines = new FriendTimelineList();

                friendtimelines.CreatedTime = ParseDateTime(GetElementValue(friendtimelinenode, "created_at"));
                friendtimelines.FriendTwitterID = GetElementValue(friendtimelinenode, "id");
                friendtimelines.FriendTwitterContent = GetElementValue(friendtimelinenode, "text");
                friendtimelines.SourceURL = GetElementValue(friendtimelinenode, "source");
                friendtimelines.IsFavorited = Convert.ToBoolean(GetElementValue(friendtimelinenode, "favorited"));
                friendtimelines.IsTruncated = Convert.ToBoolean(GetElementValue(friendtimelinenode, "truncated"));
                friendtimelines.Geo = GetElementValue(friendtimelinenode, "geo");

                friendtimelines.ReplyToStatusID = (GetElementValue(friendtimelinenode, "in_reply_to_status_id") == "" ? 0 : Convert.ToInt32(GetElementValue(friendtimelinenode, "in_reply_to_status_id")));
                friendtimelines.ReplyToUserID = (GetElementValue(friendtimelinenode, "in_reply_to_user_id") == "" ? 0 : Convert.ToInt32(GetElementValue(friendtimelinenode, "in_reply_to_user_id")));
                friendtimelines.ReplyToScreenName = GetElementValue(friendtimelinenode, "in_reply_to_screen_name");

                //friendtimelines.IsShowThumbPic = false;
                if (friendtimelinenode.XPathSelectElement("thumbnail_pic") != null)
                {
                    friendtimelines.IsShowThumbPic = true;
                    friendtimelines.ThumbnailPic = GetElementValue(friendtimelinenode, "thumbnail_pic");
                }
                else
                    friendtimelines.IsShowThumbPic = false;

                if (friendtimelinenode.XPathSelectElement("bmiddle_pic") != null)
                    friendtimelines.MiddleSizePic = GetElementValue(friendtimelinenode, "bmiddle_pic");

                if (friendtimelinenode.XPathSelectElement("original_pic") != null)
                    friendtimelines.OriginalSizePic = GetElementValue(friendtimelinenode, "original_pic");

                //friendtimelines.ThumbnailPic = friendtimelinenode.XPathSelectElement("//thumbnail_pic") == null ? "" : GetElementValue(friendtimelinenode, "thumbnail_pic");
                //friendtimelines.MiddleSizePic = friendtimelinenode.XPathSelectElement("//bmiddle_pic") == null ? "" : GetElementValue(friendtimelinenode, "bmiddle_pic");
                //friendtimelines.OriginalSizePic = friendtimelinenode.XPathSelectElement("//original_pic") == null ? "" : GetElementValue(friendtimelinenode, "original_pic");

                UserList useritem = new UserList();
                useritem.UserID = GetElementValue(friendtimelinenode.Element("user"), "id");
                useritem.TwitterName = GetElementValue(friendtimelinenode.Element("user"), "screen_name");
                useritem.FriendName = GetElementValue(friendtimelinenode.Element("user"), "name");
                useritem.Province = GetElementValue(friendtimelinenode.Element("user"), "province");
                useritem.City = GetElementValue(friendtimelinenode.Element("user"), "city");
                useritem.Location = GetElementValue(friendtimelinenode.Element("user"), "location");
                useritem.Description = GetElementValue(friendtimelinenode.Element("user"), "description");
                useritem.BlogURL = GetElementValue(friendtimelinenode.Element("user"), "url");
                useritem.CustomizeImageURL = GetElementValue(friendtimelinenode.Element("user"), "profile_image_url");
                useritem.Domain = GetElementValue(friendtimelinenode.Element("user"), "domain");
                useritem.Gender = GetElementValue(friendtimelinenode.Element("user"), "gender");
                useritem.FollowerCount = Convert.ToInt32(GetElementValue(friendtimelinenode.Element("user"), "followers_count"));
                useritem.FriendCount = Convert.ToInt32(GetElementValue(friendtimelinenode.Element("user"), "friends_count"));
                useritem.StatusesCount = Convert.ToInt32(GetElementValue(friendtimelinenode.Element("user"), "statuses_count"));
                useritem.FavouriteCount = Convert.ToInt32(GetElementValue(friendtimelinenode.Element("user"), "favourites_count"));
                useritem.CreateTime = GetElementValue(friendtimelinenode.Element("user"), "created_at");
                useritem.IsFollowing = Convert.ToBoolean(GetElementValue(friendtimelinenode.Element("user"), "following"));
                useritem.IsVerified = Convert.ToBoolean(GetElementValue(friendtimelinenode.Element("user"), "verified"));
                useritem.IsEnableGeo = Convert.ToBoolean(GetElementValue(friendtimelinenode.Element("user"), "geo_enabled"));
                friendtimelines.UsersItem = useritem;

                RetweeterList retweeteritem = new RetweeterList();

                //retweeteritem.CreatedTime = GetElementValue(friendtimelinenode.Element("retweeted_status"), "created_at");
                //retweeteritem.RetweeterID = GetElementValue(friendtimelinenode.Element("retweeted_status"), "id");
                //retweeteritem.RetweeterContent = GetElementValue(friendtimelinenode.Element("retweeted_status"), "text");
                //retweeteritem.SourceURL = GetElementValue(friendtimelinenode.Element("retweeted_status"), "source");
                //retweeteritem.IsFavorited = Convert.ToBoolean(GetElementValue(friendtimelinenode.Element("retweeted_status"), "favorited"));
                //retweeteritem.IsTruncated = Convert.ToBoolean(GetElementValue(friendtimelinenode.Element("retweeted_status"), "truncated"));
                //retweeteritem.Geo = GetElementValue(friendtimelinenode.Element("retweeted_status"), "geo");
                //var tmpReplyStatusID = GetElementValue(friendtimelinenode.Element("retweeted_status"), "in_reply_to_status_id");
                //retweeteritem.ReplyStatusID = Convert.ToInt32((tmpReplyStatusID == "") ? "0" : tmpReplyStatusID);

                //retweeteritem.ReplyUserID =Convert.ToInt32(GetElementValue(friendtimelinenode.Element("retweeted_status"), "in_reply_to_user_id"));
                //retweeteritem.ReplyToScreenName = GetElementValue(friendtimelinenode.Element("retweeted_status"), "in_reply_to_status_id");
                //retweeteritem.ThumbnailImageURL = GetElementValue(friendtimelinenode.Element("retweeted_status"), "thumbnail_pic");
                //retweeteritem.MiddleImageURL = GetElementValue(friendtimelinenode.Element("retweeted_status"), "bmiddle_pic");
                //retweeteritem.OriginalImageURL = GetElementValue(friendtimelinenode.Element("retweeted_status"), "original_pic");

                foreach (XElement subelement in friendtimelinenode.Descendants("retweeted_status"))
                {
                    retweeteritem.CreatedTime = subelement.Element(XName.Get("created_at")).Value;
                    retweeteritem.RetweeterID = subelement.Element(XName.Get("id")).Value;
                    retweeteritem.RetweeterContent = subelement.Element(XName.Get("text")).Value;
                    retweeteritem.SourceURL = subelement.Element(XName.Get("source")).Value;
                    retweeteritem.IsFavorited = Convert.ToBoolean(subelement.Element(XName.Get("favorited")).Value);
                    retweeteritem.IsTruncated = Convert.ToBoolean(subelement.Element(XName.Get("truncated")).Value);
                    retweeteritem.Geo = subelement.Element(XName.Get("geo")).Value;
                    retweeteritem.ReplyStatusID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_status_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_status_id")).Value);
                    retweeteritem.ReplyUserID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_user_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_user_id")).Value);
                    retweeteritem.ReplyToScreenName = subelement.Element(XName.Get("in_reply_to_screen_name")).Value;
                    if (subelement.XPathSelectElement("thumbnail_pic") != null)
                    {
                        retweeteritem.IsShowThumbPic = true;
                        retweeteritem.ThumbnailImageURL = subelement.Element(XName.Get("thumbnail_pic")).Value;
                    }
                    else
                        retweeteritem.IsShowThumbPic = false;

                    if (subelement.XPathSelectElement("bmiddle_pic") != null)
                    {
                        retweeteritem.IsShowThumbPic = true;
                        retweeteritem.MiddleImageURL = subelement.Element(XName.Get("bmiddle_pic")).Value;
                    }
                    else
                        retweeteritem.IsShowThumbPic = false;

                    if (subelement.XPathSelectElement("original_pic") != null)
                    {
                        retweeteritem.IsShowThumbPic = true;
                        retweeteritem.OriginalImageURL = subelement.Element(XName.Get("original_pic")).Value;
                    }
                    else
                        retweeteritem.IsShowThumbPic = false;

                    //retweeteritem.ThumbnailImageURL = subelement.XPathSelectElement("//thumbnail_pic") == null ? "" : subelement.Element(XName.Get("thumbnail_pic")).Value;
                    //retweeteritem.MiddleImageURL = subelement.XPathSelectElement("//bmiddle_pic") == null ? "" : subelement.Element(XName.Get("bmiddle_pic")).Value;
                    //retweeteritem.OriginalImageURL = subelement.XPathSelectElement("//original_pic") == null ? "" : subelement.Element(XName.Get("original_pic")).Value;

                    UserList subuseritem = new UserList();
                    subuseritem.UserID = GetElementValue(subelement.Element("user"), "id");
                    subuseritem.TwitterName = GetElementValue(subelement.Element("user"), "screen_name");
                    subuseritem.FriendName = GetElementValue(subelement.Element("user"), "name");
                    subuseritem.Province = GetElementValue(subelement.Element("user"), "province");
                    subuseritem.City = GetElementValue(subelement.Element("user"), "city");
                    subuseritem.Location = GetElementValue(subelement.Element("user"), "location");
                    subuseritem.Description = GetElementValue(subelement.Element("user"), "description");
                    subuseritem.BlogURL = GetElementValue(subelement.Element("user"), "url");
                    subuseritem.CustomizeImageURL = GetElementValue(subelement.Element("user"), "profile_image_url");
                    subuseritem.Domain = GetElementValue(subelement.Element("user"), "domain");
                    subuseritem.Gender = GetElementValue(subelement.Element("user"), "gender");
                    subuseritem.FollowerCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "followers_count"));
                    subuseritem.FriendCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "friends_count"));
                    subuseritem.StatusesCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "statuses_count"));
                    subuseritem.FavouriteCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "favourites_count"));
                    subuseritem.CreateTime = GetElementValue(subelement.Element("user"), "created_at");
                    subuseritem.IsFollowing = Convert.ToBoolean(GetElementValue(subelement.Element("user"), "following"));
                    subuseritem.IsVerified = Convert.ToBoolean(GetElementValue(subelement.Element("user"), "verified"));
                    subuseritem.IsEnableGeo = Convert.ToBoolean(GetElementValue(subelement.Element("user"), "geo_enabled"));
                    retweeteritem.UsersItem = subuseritem;

                    friendtimelines.RetweeterItem = retweeteritem;
                }

                if (friendtimelines.RetweeterItem == null)
                    friendtimelines.IsShowRetweet = false;
                else
                {
                    friendtimelines.IsShowRetweet = true;
                }

                //foreach (XElement usernode in friendtimelinenode.Element("user").Elements())
                //{
                //    UserList useritem = new UserList();
                //    useritem.UserID = GetElementValue(usernode, "id");
                //    //useritem.TwitterName = GetElementValue(usernode, "screen_name");
                //    //useritem.FriendName = GetElementValue(usernode, "name");
                //    //useritem.Province = GetElementValue(usernode, "province");
                //    //useritem.City = GetElementValue(usernode, "city");
                //    //useritem.Location = GetElementValue(usernode, "location");
                //    //useritem.Description = GetElementValue(usernode, "description");
                //    //useritem.BlogURL = GetElementValue(usernode, "url");
                //    //useritem.CustomizeImageURL = GetElementValue(usernode, "profile_image_url");
                //    //useritem.Domain = GetElementValue(usernode, "domain");
                //    //useritem.Gender = GetElementValue(usernode, "gender");
                //    //useritem.FollowerCount = Convert.ToInt32(GetElementValue(usernode, "followers_count"));
                //    //useritem.FriendCount = Convert.ToInt32(GetElementValue(usernode, "friends_count"));
                //    //useritem.StatusesCount = Convert.ToInt32(GetElementValue(usernode, "statuses_count"));
                //    //useritem.FavouriteCount = Convert.ToInt32(GetElementValue(usernode, "favourites_count"));
                //    //useritem.CreateTime = GetElementValue(usernode, "created_at");
                //    //useritem.IsFollowing = Convert.ToBoolean(GetElementValue(usernode, "following"));
                //    //useritem.IsVerified = Convert.ToBoolean(GetElementValue(usernode, "verified"));
                //    //useritem.IsEnableGeo = Convert.ToBoolean(GetElementValue(usernode, "geo_enabled"));
                //    friendtimelines.UsersItem = useritem;
                //}

                friendtimecollection.Add(friendtimelines);
            }

            //friendtimelines.CreatedTime = GetGroupElementValue(element, "created_at");
            ////friendtimelines.CreatedTime = GetElementValue(GetElementValue(element, "created_at"),"status");
            //friendtimelines.FriendTwitterID = GetGroupElementValue(element, "id");
            //friendtimelines.FriendTwitterContent = GetGroupElementValue(element, "text");
            //friendtimelines.SourceURL = GetGroupElementValue(element, "source");
            //friendtimelines.IsFavorited = Convert.ToBoolean(GetGroupElementValue(element, "favorited"));
            //friendtimelines.IsTruncated = Convert.ToBoolean(GetGroupElementValue(element, "truncated"));
            //friendtimelines.Geo = GetGroupElementValue(element, "geo");

            //friendtimelines.ReplyToStatusID = (GetGroupElementValue(element, "in_reply_to_status_id") == "" ? 0 : Convert.ToInt32(GetGroupElementValue(element, "in_reply_to_status_id")));
            //friendtimelines.ReplyToUserID = (GetGroupElementValue(element, "in_reply_to_user_id") == "" ? 0 : Convert.ToInt32(GetGroupElementValue(element, "in_reply_to_user_id")));
            //friendtimelines.ReplyToScreenName = GetGroupElementValue(element, "in_reply_to_screen_name");
            //friendtimelines.UsersItem

            //UserList userInfo = new UserList();

            //var tmpURL = (from status in element.Descendants("")

            return friendtimecollection;
        }
Ejemplo n.º 2
0
        public static FavoriteList Parse(XElement element, int Status)
        {
            FavoriteList favorites = new FavoriteList();

            favorites.CreatedTime = ParseDateTime(GetElementValue(element, "created_at"));
            favorites.FriendTwitterID = GetElementValue(element, "id");
            favorites.FriendTwitterContent = GetElementValue(element, "text");
            favorites.SourceURL = GetElementValue(element, "source");
            favorites.IsFavorited = Convert.ToBoolean(GetElementValue(element, "favorited"));
            favorites.IsTruncated = Convert.ToBoolean(GetElementValue(element, "truncated"));
            favorites.Geo = GetElementValue(element, "geo");

            favorites.ReplyToStatusID = (GetElementValue(element, "in_reply_to_status_id") == "" ? 0 : Convert.ToInt32(GetElementValue(element, "in_reply_to_status_id")));
            favorites.ReplyToUserID = (GetElementValue(element, "in_reply_to_user_id") == "" ? 0 : Convert.ToInt32(GetElementValue(element, "in_reply_to_user_id")));
            favorites.ReplyToScreenName = GetElementValue(element, "in_reply_to_screen_name");

            if (element.XPathSelectElement("thumbnail_pic") != null)
            {
                favorites.IsShowThumbPic = true;
                favorites.ThumbnailPic = GetElementValue(element, "thumbnail_pic");
            }
            else
                favorites.IsShowThumbPic = false;

            if (element.XPathSelectElement("bmiddle_pic") != null)
                favorites.MiddleSizePic = GetElementValue(element, "bmiddle_pic");

            if (element.XPathSelectElement("original_pic") != null)
                favorites.OriginalSizePic = GetElementValue(element, "original_pic");

            UserList useritem = new UserList();
            useritem.UserID = GetElementValue(element.Element("user"), "id");
            useritem.TwitterName = GetElementValue(element.Element("user"), "screen_name");
            useritem.FriendName = GetElementValue(element.Element("user"), "name");
            useritem.Province = GetElementValue(element.Element("user"), "province");
            useritem.City = GetElementValue(element.Element("user"), "city");
            useritem.Location = GetElementValue(element.Element("user"), "location");
            useritem.Description = GetElementValue(element.Element("user"), "description");
            useritem.BlogURL = GetElementValue(element.Element("user"), "url");
            useritem.CustomizeImageURL = GetElementValue(element.Element("user"), "profile_image_url");
            useritem.Domain = GetElementValue(element.Element("user"), "domain");
            useritem.Gender = GetElementValue(element.Element("user"), "gender");
            useritem.FollowerCount = Convert.ToInt32(GetElementValue(element.Element("user"), "followers_count"));
            useritem.FriendCount = Convert.ToInt32(GetElementValue(element.Element("user"), "friends_count"));
            useritem.StatusesCount = Convert.ToInt32(GetElementValue(element.Element("user"), "statuses_count"));
            useritem.FavouriteCount = Convert.ToInt32(GetElementValue(element.Element("user"), "favourites_count"));
            useritem.CreateTime = GetElementValue(element.Element("user"), "created_at");
            useritem.IsFollowing = Convert.ToBoolean(GetElementValue(element.Element("user"), "following"));
            useritem.IsVerified = Convert.ToBoolean(GetElementValue(element.Element("user"), "verified"));
            useritem.IsEnableGeo = Convert.ToBoolean(GetElementValue(element.Element("user"), "geo_enabled"));
            favorites.UsersItem = useritem;

            RetweeterList retweeteritem = new RetweeterList();

            foreach (XElement subelement in element.Descendants("retweeted_status"))
            {
                retweeteritem.CreatedTime = subelement.Element(XName.Get("created_at")).Value;
                retweeteritem.RetweeterID = subelement.Element(XName.Get("id")).Value;
                retweeteritem.RetweeterContent = subelement.Element(XName.Get("text")).Value;
                retweeteritem.SourceURL = subelement.Element(XName.Get("source")).Value;
                retweeteritem.IsFavorited = Convert.ToBoolean(subelement.Element(XName.Get("favorited")).Value);
                retweeteritem.IsTruncated = Convert.ToBoolean(subelement.Element(XName.Get("truncated")).Value);
                retweeteritem.Geo = subelement.Element(XName.Get("geo")).Value;
                retweeteritem.ReplyStatusID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_status_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_status_id")).Value);
                retweeteritem.ReplyUserID = Convert.ToInt32((subelement.Element(XName.Get("in_reply_to_user_id")).Value == "") ? "0" : subelement.Element(XName.Get("in_reply_to_user_id")).Value);
                retweeteritem.ReplyToScreenName = subelement.Element(XName.Get("in_reply_to_screen_name")).Value;
                if (subelement.XPathSelectElement("thumbnail_pic") != null)
                {
                    retweeteritem.IsShowThumbPic = true;
                    retweeteritem.ThumbnailImageURL = subelement.Element(XName.Get("thumbnail_pic")).Value;
                }
                else
                    retweeteritem.IsShowThumbPic = false;

                if (subelement.XPathSelectElement("bmiddle_pic") != null)
                {
                    retweeteritem.IsShowThumbPic = true;
                    retweeteritem.MiddleImageURL = subelement.Element(XName.Get("bmiddle_pic")).Value;
                }
                else
                    retweeteritem.IsShowThumbPic = false;

                if (subelement.XPathSelectElement("original_pic") != null)
                {
                    retweeteritem.IsShowThumbPic = true;
                    retweeteritem.OriginalImageURL = subelement.Element(XName.Get("original_pic")).Value;
                }
                else
                    retweeteritem.IsShowThumbPic = false;

                UserList subuseritem = new UserList();
                subuseritem.UserID = GetElementValue(subelement.Element("user"), "id");
                subuseritem.TwitterName = GetElementValue(subelement.Element("user"), "screen_name");
                subuseritem.FriendName = GetElementValue(subelement.Element("user"), "name");
                subuseritem.Province = GetElementValue(subelement.Element("user"), "province");
                subuseritem.City = GetElementValue(subelement.Element("user"), "city");
                subuseritem.Location = GetElementValue(subelement.Element("user"), "location");
                subuseritem.Description = GetElementValue(subelement.Element("user"), "description");
                subuseritem.BlogURL = GetElementValue(subelement.Element("user"), "url");
                subuseritem.CustomizeImageURL = GetElementValue(subelement.Element("user"), "profile_image_url");
                subuseritem.Domain = GetElementValue(subelement.Element("user"), "domain");
                subuseritem.Gender = GetElementValue(subelement.Element("user"), "gender");
                subuseritem.FollowerCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "followers_count"));
                subuseritem.FriendCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "friends_count"));
                subuseritem.StatusesCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "statuses_count"));
                subuseritem.FavouriteCount = Convert.ToInt32(GetElementValue(subelement.Element("user"), "favourites_count"));
                subuseritem.CreateTime = GetElementValue(subelement.Element("user"), "created_at");
                subuseritem.IsFollowing = Convert.ToBoolean(GetElementValue(subelement.Element("user"), "following"));
                subuseritem.IsVerified = Convert.ToBoolean(GetElementValue(subelement.Element("user"), "verified"));
                subuseritem.IsEnableGeo = Convert.ToBoolean(GetElementValue(subelement.Element("user"), "geo_enabled"));
                retweeteritem.UsersItem = subuseritem;

                favorites.RetweeterItem = retweeteritem;
            }

            if (favorites.RetweeterItem == null)
                favorites.IsShowRetweet = false;
            else
            {
                favorites.IsShowRetweet = true;
            }

            return favorites;
        }