コード例 #1
0
        /// <summary>
        /// transforms XML into IQueryable of User
        /// </summary>
        /// <param name="twitterResponse">xml with Twitter response</param>
        /// <returns>IQueryable of User</returns>
        public virtual List <T> ProcessResults(XElement twitterResponse)
        {
            var friendship =
                new Friendship
            {
                Type             = Type,
                SubjectUser      = SubjectUser,
                FollowingUser    = FollowingUser,
                SourceUserID     = SourceUserID,
                SourceScreenName = SourceScreenName,
                TargetUserID     = TargetUserID,
                TargetScreenName = TargetScreenName,
                Cursor           = Cursor
            };

            if (twitterResponse.Name == "relationship") // Show
            {
                var relationship = new Relationship();

                friendship.SourceRelationship =
                    relationship.CreateRelationship(twitterResponse.Element("source"));
                friendship.TargetRelationship =
                    relationship.CreateRelationship(twitterResponse.Element("target"));
            }
            else if (twitterResponse.Name == "id_list") // incoming/outgoing
            {
                friendship.IDInfo = new IDList().CreateIDList(twitterResponse);
            }
            else // Exists
            {
                friendship.IsFriend = bool.Parse(twitterResponse.Value);
            }

            var friendList = new List <Friendship>
            {
                friendship
            };

            return(friendList.OfType <T>().ToList());
        }
コード例 #2
0
        /// <summary>
        /// transforms XML into IQueryable of User
        /// </summary>
        /// <param name="responseXml">xml with Twitter response</param>
        /// <returns>IQueryable of User</returns>
        public virtual List <T> ProcessResults(string responseXml)
        {
            XElement twitterResponse = XElement.Parse(responseXml);
            var      friendship      =
                new Friendship
            {
                Type             = Type,
                SubjectUser      = SubjectUser,
                FollowingUser    = FollowingUser,
                SourceUserID     = SourceUserID,
                SourceScreenName = SourceScreenName,
                TargetUserID     = TargetUserID,
                TargetScreenName = TargetScreenName,
                Cursor           = Cursor,
                ScreenName       = ScreenName
            };

            if (twitterResponse.Name == "relationship") // Show
            {
                friendship.SourceRelationship =
                    Relationship.CreateRelationship(twitterResponse.Element("source"));
                friendship.TargetRelationship =
                    Relationship.CreateRelationship(twitterResponse.Element("target"));
            }
            else if (twitterResponse.Name == "relationships")
            {
                friendship.Relationships =
                    (from relElem in twitterResponse.Elements("relationship")
                     select Relationship.CreateRelationship(relElem))
                    .ToList();
            }
            else if (twitterResponse.Name == "id_list") // incoming/outgoing
            {
                friendship.IDInfo = IDList.CreateIDList(twitterResponse);
            }
            else // Exists
            {
                friendship.IsFriend = bool.Parse(twitterResponse.Value);
            }

            var friendList = new List <Friendship>
            {
                friendship
            };

            return(friendList.OfType <T>().ToList());
        }