Ejemplo n.º 1
0
        /// <summary>
        /// transforms XML into IQueryable of DirectMessage
        /// </summary>
        /// <param name="responseXml">xml with Twitter response</param>
        /// <returns>List of DirectMessage</returns>
        public virtual List <T> ProcessResults(string responseXml)
        {
            XElement twitterResponse = XElement.Parse(responseXml);
            var      responseItems   = twitterResponse.Elements("direct_message").ToList();

            // if we get only a single response back,
            // make sure we get it
            if (twitterResponse.Name == "direct_message")
            {
                responseItems.Add(twitterResponse);
            }

            var dmList =
                from dm in responseItems
                let sender =
                    dm.Element("sender")
                    let recipient =
                        dm.Element("recipient")
                        let createdAtDate =
                            DateTime.ParseExact(
                                dm.Element("created_at").Value,
                                "ddd MMM dd HH:mm:ss %zzzz yyyy",
                                CultureInfo.InvariantCulture)
                            select new DirectMessage
            {
                Type                = Type,
                SinceID             = SinceID,
                MaxID               = MaxID,
                Page                = Page,
                Count               = Count,
                ID                  = ulong.Parse(dm.Element("id").Value),
                SenderID            = ulong.Parse(dm.Element("sender_id").Value),
                Text                = dm.Element("text").Value,
                RecipientID         = ulong.Parse(dm.Element("recipient_id").Value),
                CreatedAt           = createdAtDate,
                SenderScreenName    = dm.Element("sender_screen_name").Value,
                RecipientScreenName = dm.Element("recipient_screen_name").Value,
                Sender              = User.CreateUser(sender),
                Recipient           = User.CreateUser(recipient)
            };

            return(dmList.OfType <T>().ToList());
        }
Ejemplo n.º 2
0
 public static List CreateList(XElement list, XElement cursorNode)
 {
     return(new List
     {
         ListID = list.Element("id").Value,
         Name = list.Element("name").Value,
         FullName = list.Element("full_name").Value,
         Slug = list.Element("slug").Value,
         Description = list.Element("description").Value,
         SubscriberCount = int.Parse(list.Element("subscriber_count").Value),
         MemberCount = int.Parse(list.Element("member_count").Value),
         Uri = list.Element("uri").Value,
         Mode = list.Element("mode").Value,
         Users = new List <User>
         {
             User.CreateUser(list.Element("user"))
         },
         CursorMovement = Cursors.CreateCursors(cursorNode)
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// appends parameters for Search request
        /// </summary>
        /// <param name="parameters">list of parameters from expression tree</param>
        /// <param name="url">base url</param>
        /// <returns>base url + parameters</returns>
        public virtual List <T> ProcessResults(XElement twitterResponse)
        {
            var blocks = new Blocks
            {
                Type       = Type,
                ID         = ID,
                UserID     = UserID,
                ScreenName = ScreenName,
                Page       = Page
            };

            if (twitterResponse.Name == "user")
            {
                blocks.User = new User().CreateUser(twitterResponse);
            }
            else if (twitterResponse.Name == "users")
            {
                var usr = new User();
                blocks.Users =
                    (from user in twitterResponse.Elements("user").ToList()
                     select usr.CreateUser(user))
                    .ToList();
            }
            else if (twitterResponse.Name == "ids")
            {
                blocks.IDs =
                    (from id in twitterResponse.Elements("id").ToList()
                     select id.Value)
                    .ToList();
            }
            else
            {
                throw new ArgumentException("Account Results Processing expected a Twitter response for either a user or hash, but received an unknown element type instead.");
            }

            return(new List <Blocks> {
                blocks
            }.OfType <T>().ToList());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Shreds an XML element into a Status object
        /// </summary>
        /// <param name="status">XML element with info</param>
        /// <returns>Newly populated status object</returns>
        public Status CreateStatus(XElement status)
        {
            if (status == null)
            {
                return null;
            }

            var dateParts =
                status.Element("created_at").Value.Split(' ');

            var createdAtDate =
                dateParts.Count() > 1 ?
                DateTime.Parse(
                    string.Format("{0} {1} {2} {3} GMT",
                    dateParts[1],
                    dateParts[2],
                    dateParts[5],
                    dateParts[3]),
                    CultureInfo.InvariantCulture) :
                DateTime.MinValue;

            var user = status.Element("user");

            var retweet = status.Element("retweeted_status");

            var rtDateParts =
                retweet == null ?
                    null :
                    retweet.Element("created_at").Value.Split(' ');

            var retweetedAtDate =
                retweet == null ?
                    DateTime.MinValue :
                    DateTime.Parse(
                        string.Format("{0} {1} {2} {3} GMT",
                        rtDateParts[1],
                        rtDateParts[2],
                        rtDateParts[5],
                        rtDateParts[3]),
                        CultureInfo.InvariantCulture);

            List<string> contributorIDs = null;

            if (status.Element("contributors") != null)
            {
                contributorIDs =
                    (from id in status.Element("contributors").Elements("user_id")
                     select id.Value)
                     .ToList();
            }

            XNamespace geoRss = "http://www.georss.org/georss";

            var geoStr =
               status.Element("geo") != null &&
               status.Element("geo").Element(geoRss + "point") != null ?
                   status.Element("geo").Element(geoRss + "point").Value :
                   string.Empty;

            Geo geo = new Geo();
            if (!string.IsNullOrEmpty(geoStr))
            {
                var coordArr = geoStr.Split(' ');

                double tempLatitude = 0;
                double tempLongitide = 0;

                if (double.TryParse(coordArr[Coordinate.LatitudePos], out tempLatitude) &&
                    double.TryParse(coordArr[Coordinate.LongitudePos], out tempLongitide))
                {
                    geo =
                        new Geo
                        {
                            Latitude = tempLatitude,
                            Longitude = tempLongitide
                        };
                }
            }

            var coordStr =
                status.Element("coordinates") != null &&
                status.Element("coordinates").Element(geoRss + "point") != null ?
                    status.Element("coordinates").Element(geoRss + "point").Value :
                    string.Empty;

            Coordinate coord = new Coordinate();
            if (!string.IsNullOrEmpty(coordStr))
            {
                var coordArr = coordStr.Split(' ');

                double tempLatitude = 0;
                double tempLongitide = 0;

                if (double.TryParse(coordArr[Coordinate.LatitudePos], out tempLatitude) &&
                    double.TryParse(coordArr[Coordinate.LongitudePos], out tempLongitide))
                {
                    coord =
                        new Coordinate
                        {
                            Latitude = tempLatitude,
                            Longitude = tempLongitide
                        };
                }
            }

            var place = new Place().CreatePlace(status.Element("place"));

            var usr = new User();

            var newStatus = new Status
            {
                CreatedAt = createdAtDate,
                Favorited =
                 bool.Parse(
                     string.IsNullOrEmpty(status.Element("favorited").Value) ?
                     "true" :
                     status.Element("favorited").Value),
                StatusID = status.Element("id").Value,
                InReplyToStatusID = status.Element("in_reply_to_status_id").Value,
                InReplyToUserID = status.Element("in_reply_to_user_id").Value,
                Source = status.Element("source").Value,
                Text = status.Element("text").Value,
                Truncated = bool.Parse(status.Element("truncated").Value),
                InReplyToScreenName =
                     status.Element("in_reply_to_screen_name") == null ?
                         string.Empty :
                         status.Element("in_reply_to_screen_name").Value,
                ContributorIDs = contributorIDs,
                Geo = geo,
                Coordinates = coord,
                Place = place,
                User = usr.CreateUser(user),
                Retweet =
                    retweet == null ?
                        null :
                        new Retweet
                        {
                            ID = retweet.Element("id").Value,
                            CreatedAt = retweetedAtDate,
                            Favorited =
                                bool.Parse(
                                    string.IsNullOrEmpty(retweet.Element("favorited").Value) ?
                                    "true" :
                                    retweet.Element("favorited").Value),
                            InReplyToScreenName = retweet.Element("in_reply_to_screen_name").Value,
                            InReplyToStatusID = retweet.Element("in_reply_to_status_id").Value,
                            InReplyToUserID = retweet.Element("in_reply_to_user_id").Value,
                            Source = retweet.Element("source").Value,
                            Text = retweet.Element("text").Value,
                            Truncated =
                                bool.Parse(
                                    string.IsNullOrEmpty(retweet.Element("truncated").Value) ?
                                    "true" :
                                    retweet.Element("truncated").Value),
                            RetweetingUser = usr.CreateUser(retweet.Element("user"))
                        }
            };

            return newStatus;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Shreds an XML element into a Status object
        /// </summary>
        /// <param name="status">XML element with info</param>
        /// <returns>Newly populated status object</returns>
        public static Status CreateStatus(XElement status)
        {
            if (status == null)
            {
                return(null);
            }

            var createdAtDate =
                status.Element("created_at") == null ||
                status.Element("created_at").Value == string.Empty
                    ? DateTime.MinValue
                    : DateTime.ParseExact(
                    status.Element("created_at").Value,
                    "ddd MMM dd HH:mm:ss %zzzz yyyy",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);

            var favorite =
                status.Element("favorited") == null ||
                status.Element("favorited").Value == string.Empty ?
                "false" :
                status.Element("favorited").Value;

            var user    = status.Element("user");
            var retweet = status.Element("retweeted_status");

            var retweetCount =
                status.Element("retweet_count") == null ||
                status.Element("retweet_count").Value == string.Empty ?
                0 :
                int.Parse(status.Element("retweet_count").Value.TrimEnd('+'));

            var retweeted =
                status.Element("retweeted") == null || status.Element("retweeted").Value == string.Empty ?
                false :
                bool.Parse(status.Element("retweeted").Value);

            var retweetDate = retweet == null
                              ? null
                              : retweet.Element("created_at").Value;

            var retweetedAtDate = String.IsNullOrEmpty(retweetDate)
                                ? DateTime.MinValue
                                : DateTime.ParseExact(
                retweetDate,
                "ddd MMM dd HH:mm:ss %zzzz yyyy",
                CultureInfo.InvariantCulture,
                DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);


            List <Contributor> contributors = null;

            XElement contributorElement = status.Element("contributors");

            if (contributorElement != null)
            {
                if (contributorElement.Elements("user").Count() > 0)
                {
                    contributors =
                        (from contr in contributorElement.Elements("user")
                         select new Contributor
                    {
                        ID = contr.Element("id").Value,
                        ScreenName = contr.Element("screen_name").Value
                    })
                        .ToList();
                }
                else
                {
                    contributors =
                        (from id in contributorElement.Elements("user_id")
                         select new Contributor
                    {
                        ID = id.Value,
                        ScreenName = string.Empty
                    })
                        .ToList();
                }
            }

            XNamespace geoRss = "http://www.georss.org/georss";

            var geoStr =
                status.Element("geo") != null &&
                status.Element("geo").Element(geoRss + "point") != null?
                status.Element("geo").Element(geoRss + "point").Value:
                string.Empty;

            Geo geo = new Geo();

            if (!string.IsNullOrEmpty(geoStr))
            {
                var coordArr = geoStr.Split(' ');

                double tempLatitude  = 0;
                double tempLongitide = 0;

                if (double.TryParse(coordArr[Coordinate.LatitudePos], out tempLatitude) &&
                    double.TryParse(coordArr[Coordinate.LongitudePos], out tempLongitide))
                {
                    geo =
                        new Geo
                    {
                        Latitude  = tempLatitude,
                        Longitude = tempLongitide
                    };
                }
            }

            var coordStr =
                status.Element("coordinates") != null &&
                status.Element("coordinates").Element(geoRss + "point") != null?
                status.Element("coordinates").Element(geoRss + "point").Value:
                string.Empty;

            Coordinate coord = new Coordinate();

            if (!string.IsNullOrEmpty(coordStr))
            {
                var coordArr = coordStr.Split(' ');

                double tempLatitude  = 0;
                double tempLongitide = 0;

                if (double.TryParse(coordArr[Coordinate.LatitudePos], out tempLatitude) &&
                    double.TryParse(coordArr[Coordinate.LongitudePos], out tempLongitide))
                {
                    coord =
                        new Coordinate
                    {
                        Latitude  = tempLatitude,
                        Longitude = tempLongitide
                    };
                }
            }

            var place      = Place.CreatePlace(status.Element("place"));
            var annotation = Annotation.CreateAnnotation(status.Element("annotation"));
            var entities   = Entities.CreateEntities(status.Element("entities"));

            var newStatus = new Status
            {
                CreatedAt         = createdAtDate,
                Favorited         = bool.Parse(favorite),
                StatusID          = status.GetString("id"),
                InReplyToStatusID = status.GetString("in_reply_to_status_id"),
                InReplyToUserID   = status.GetString("in_reply_to_user_id"),
                Source            = status.GetString("source"),
                Text                = status.GetString("text"),
                Truncated           = status.GetBool("truncated"),
                InReplyToScreenName = status.GetString("in_reply_to_screen_name"),
                Contributors        = contributors,
                Geo          = geo,
                Coordinates  = coord,
                Place        = place,
                Annotation   = annotation,
                User         = User.CreateUser(user),
                Entities     = entities,
                Retweeted    = retweeted,
                RetweetCount = retweetCount,
                Retweet      =
                    retweet == null ?
                    null :
                    new Retweet
                {
                    ID                  = retweet.GetString("id"),
                    CreatedAt           = retweetedAtDate,
                    Favorited           = retweet.GetBool("favorited"),
                    InReplyToScreenName = retweet.GetString("in_reply_to_screen_name"),
                    InReplyToStatusID   = retweet.GetString("in_reply_to_status_id"),
                    InReplyToUserID     = retweet.GetString("in_reply_to_user_id"),
                    Source              = retweet.GetString("source"),
                    Text                = retweet.GetString("text"),
                    Retweeted           = retweet.GetBool("retweeted"),
                    RetweetCount        =
                        //retweet.GetInt("retweet_count"),
                        retweet.Element("retweet_count") == null ||
                        retweet.Element("retweet_count").Value == string.Empty ?
                        0 :
                        int.Parse(retweet.Element("retweet_count").Value.TrimEnd('+')),
                    Truncated      = retweet.GetBool("truncated", true),
                    RetweetingUser = User.CreateUser(retweet.Element("user"))
                }
            };

            return(newStatus);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Shreds an XML element into a Status object
        /// </summary>
        /// <param name="status">XML element with info</param>
        /// <returns>Newly populated status object</returns>
        public Status CreateStatus(XElement status)
        {
            if (status == null)
            {
                return(null);
            }

            var dateParts =
                status.Element("created_at").Value.Split(' ');

            var createdAtDate =
                dateParts.Count() > 1 ?
                DateTime.Parse(
                    string.Format("{0} {1} {2} {3} GMT",
                                  dateParts[1],
                                  dateParts[2],
                                  dateParts[5],
                                  dateParts[3]),
                    CultureInfo.InvariantCulture) :
                DateTime.MinValue;

            var user = status.Element("user");

            var retweet = status.Element("retweeted_status");

            var rtDateParts =
                retweet == null ?
                null :
                retweet.Element("created_at").Value.Split(' ');

            var retweetedAtDate =
                retweet == null ?
                DateTime.MinValue :
                DateTime.Parse(
                    string.Format("{0} {1} {2} {3} GMT",
                                  rtDateParts[1],
                                  rtDateParts[2],
                                  rtDateParts[5],
                                  rtDateParts[3]),
                    CultureInfo.InvariantCulture);

            List <string> contributorIDs = null;

            if (status.Element("contributors") != null)
            {
                contributorIDs =
                    (from id in status.Element("contributors").Elements("user_id")
                     select id.Value)
                    .ToList();
            }

            XNamespace geoRss = "http://www.georss.org/georss";

            var geoStr =
                status.Element("geo") != null &&
                status.Element("geo").Element(geoRss + "point") != null?
                status.Element("geo").Element(geoRss + "point").Value:
                string.Empty;

            Geo geo = new Geo();

            if (!string.IsNullOrEmpty(geoStr))
            {
                var coordArr = geoStr.Split(' ');

                double tempLatitude  = 0;
                double tempLongitide = 0;

                if (double.TryParse(coordArr[Coordinate.LatitudePos], out tempLatitude) &&
                    double.TryParse(coordArr[Coordinate.LongitudePos], out tempLongitide))
                {
                    geo =
                        new Geo
                    {
                        Latitude  = tempLatitude,
                        Longitude = tempLongitide
                    };
                }
            }

            var coordStr =
                status.Element("coordinates") != null &&
                status.Element("coordinates").Element(geoRss + "point") != null?
                status.Element("coordinates").Element(geoRss + "point").Value:
                string.Empty;

            Coordinate coord = new Coordinate();

            if (!string.IsNullOrEmpty(coordStr))
            {
                var coordArr = coordStr.Split(' ');

                double tempLatitude  = 0;
                double tempLongitide = 0;

                if (double.TryParse(coordArr[Coordinate.LatitudePos], out tempLatitude) &&
                    double.TryParse(coordArr[Coordinate.LongitudePos], out tempLongitide))
                {
                    coord =
                        new Coordinate
                    {
                        Latitude  = tempLatitude,
                        Longitude = tempLongitide
                    };
                }
            }

            var place = new Place().CreatePlace(status.Element("place"));

            var usr = new User();

            var newStatus = new Status
            {
                CreatedAt = createdAtDate,
                Favorited =
                    bool.Parse(
                        string.IsNullOrEmpty(status.Element("favorited").Value) ?
                        "true" :
                        status.Element("favorited").Value),
                StatusID          = status.Element("id").Value,
                InReplyToStatusID = status.Element("in_reply_to_status_id").Value,
                InReplyToUserID   = status.Element("in_reply_to_user_id").Value,
                Source            = status.Element("source").Value,
                Text                = status.Element("text").Value,
                Truncated           = bool.Parse(status.Element("truncated").Value),
                InReplyToScreenName =
                    status.Element("in_reply_to_screen_name") == null ?
                    string.Empty :
                    status.Element("in_reply_to_screen_name").Value,
                ContributorIDs = contributorIDs,
                Geo            = geo,
                Coordinates    = coord,
                Place          = place,
                User           = usr.CreateUser(user),
                Retweet        =
                    retweet == null ?
                    null :
                    new Retweet
                {
                    ID        = retweet.Element("id").Value,
                    CreatedAt = retweetedAtDate,
                    Favorited =
                        bool.Parse(
                            string.IsNullOrEmpty(retweet.Element("favorited").Value) ?
                            "true" :
                            retweet.Element("favorited").Value),
                    InReplyToScreenName = retweet.Element("in_reply_to_screen_name").Value,
                    InReplyToStatusID   = retweet.Element("in_reply_to_status_id").Value,
                    InReplyToUserID     = retweet.Element("in_reply_to_user_id").Value,
                    Source    = retweet.Element("source").Value,
                    Text      = retweet.Element("text").Value,
                    Truncated =
                        bool.Parse(
                            string.IsNullOrEmpty(retweet.Element("truncated").Value) ?
                            "true" :
                            retweet.Element("truncated").Value),
                    RetweetingUser = usr.CreateUser(retweet.Element("user"))
                }
            };

            return(newStatus);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// transforms XML into IList of User
        /// </summary>
        /// <param name="responseXml">xml with Twitter response</param>
        /// <returns>List of User</returns>
        public virtual List <T> ProcessResults(string responseXml)
        {
            XElement twitterResponse = XElement.Parse(responseXml);
            var      userList        = new List <User>();
            var      categories      = new List <Category>();

            var isRoot        = twitterResponse.Name == "root";
            var responseItems = twitterResponse.Elements("root").ToList();

            string rootElement =
                isRoot || responseItems.Count > 0 ? "root" : "user";

            if (responseItems.Count == 0)
            {
                responseItems = twitterResponse.Elements(rootElement).ToList();
            }

            if (twitterResponse.Element("users") != null)
            {
                responseItems =
                    (from user in twitterResponse.Element("users").Elements("user").ToList()
                     select user)
                    .ToList();
            }

            if (twitterResponse.Name == "suggestions" && twitterResponse.Elements("user").Count() == 0)
            {
                userList.Add(new User());

                categories =
                    (from cat in twitterResponse.Elements("category")
                     select Category.CreateCategory(cat))
                    .ToList();
            }

            // if we get only a single response back,
            // such as a Show request, make sure we get it
            if (twitterResponse.Name == rootElement)
            {
                responseItems.Add(twitterResponse);
            }

            var users =
                (from user in responseItems
                 select User.CreateUser(user))
                .ToList();

            userList.AddRange(users);

            userList.ForEach(
                user =>
            {
                user.Type       = Type;
                user.ID         = ID;
                user.UserID     = UserID;
                user.ScreenName = ScreenName;
                user.Page       = Page;
                user.Cursor     = Cursor;
                user.Slug       = Slug;
                user.Categories = categories;
                user.Lang       = Lang;
            });

            return(userList.OfType <T>().ToList());
        }
Ejemplo n.º 8
0
        public void CreateUserTest()
        {
            User target = new User();
            XElement user = XElement.Parse(m_userXml);
            User expected = new User()
            {
                 CreatedAt = new DateTime(2008, 7, 13, 4, 35, 50),
                 Description = "Created LINQ to Twitter, author of LINQ Programming/McGraw-Hill, .NET Consulting, and Microsoft MVP",
                 Name = "Joe Mayo",
                 Following = false
            };

            User actual = target.CreateUser(user);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Following, actual.Following);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// transforms XML into IQueryable of User
        /// </summary>
        /// <param name="responseXml">xml with Twitter response</param>
        /// <returns>List of User</returns>
        public virtual List <T> ProcessResults(string responseXml)
        {
            XElement twitterResponse = XElement.Parse(responseXml);
            var      acct            = new Account {
                Type = Type
            };

            if (twitterResponse.Name == "user")
            {
                var user = User.CreateUser(twitterResponse);

                acct.User = user;
            }
            else if (twitterResponse.Name == "hash")
            {
                if (twitterResponse.Element("hourly-limit") != null)
                {
                    var rateLimits = new RateLimitStatus
                    {
                        HourlyLimit   = int.Parse(twitterResponse.Element("hourly-limit").Value),
                        RemainingHits = int.Parse(twitterResponse.Element("remaining-hits").Value),
                        ResetTime     = DateTime.Parse(twitterResponse.Element("reset-time").Value,
                                                       CultureInfo.InvariantCulture,
                                                       DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal),
                        ResetTimeInSeconds = int.Parse(twitterResponse.Element("reset-time-in-seconds").Value)
                    };

                    acct.RateLimitStatus = rateLimits;
                }
                else if (twitterResponse.Element("request") != null)
                {
                    var endSession = new TwitterHashResponse
                    {
                        Request = twitterResponse.Element("request").Value,
                        Error   = twitterResponse.Element("error").Value
                    };

                    acct.EndSessionStatus = endSession;
                }
                else
                {
                    acct.Totals = new Totals
                    {
                        Updates   = int.Parse(twitterResponse.Element("updates").Value),
                        Friends   = int.Parse(twitterResponse.Element("friends").Value),
                        Favorites = int.Parse(twitterResponse.Element("favorites").Value),
                        Followers = int.Parse(twitterResponse.Element("followers").Value)
                    };
                }
            }
            else if (twitterResponse.Name == "settings")
            {
                acct.Settings = new Settings
                {
                    TrendLocation = Location.CreateLocation(twitterResponse.Element("trend_location")),
                    GeoEnabled    = bool.Parse(twitterResponse.Element("geo_enabled").Value),
                    SleepTime     = SleepTime.CreateSleepTime(twitterResponse.Element("sleep_time"))
                };
            }
            else
            {
                throw new ArgumentException("Account Results Processing expected a Twitter response for either a user or hash, but received an unknown element type instead.");
            }

            return(new List <Account> {
                acct
            }.OfType <T>().ToList());
        }
Ejemplo n.º 10
0
        /// <summary>
        /// transforms XML into IList of List
        /// </summary>
        /// <param name="responseXml">xml with Twitter response</param>
        /// <returns>IList of List</returns>
        public virtual List <T> ProcessResults(string responseXml)
        {
            XElement    twitterResponse = XElement.Parse(responseXml);
            List <List> lists           = new List <List>();

            if (twitterResponse.Name == "lists_list" || twitterResponse.Name == "lists")
            {
                IEnumerable <XElement> listElements =
                    twitterResponse.Name == "lists_list" ?
                    twitterResponse.Element("lists").Elements("list") :
                    twitterResponse.Elements("list");

                lists =
                    (from list in listElements
                     select List.CreateList(list, twitterResponse))
                    .ToList();
            }
            else if (twitterResponse.Name == "list")
            {
                lists.Add(
                    List.CreateList(twitterResponse, twitterResponse)
                    );
            }
            else if (twitterResponse.Name == "users_list")
            {
                lists.Add(
                    new List
                {
                    Users =
                        (from user in twitterResponse.Element("users").Elements("user")
                         select User.CreateUser(user))
                        .ToList(),
                    CursorMovement = Cursors.CreateCursors(twitterResponse)
                });
            }
            else if (twitterResponse.Name == "user")
            {
                lists.Add(
                    new List
                {
                    Users = new List <User>
                    {
                        User.CreateUser(twitterResponse)
                    }
                });
            }
            else if (twitterResponse.Name == "statuses")
            {
                lists.Add(
                    new List
                {
                    Statuses =
                        (from status in twitterResponse.Elements("status")
                         select Status.CreateStatus(status))
                        .ToList(),
                    CursorMovement = Cursors.CreateCursors(twitterResponse)
                });
            }

            lists.ForEach(list =>
            {
                list.Type   = Type;
                list.Cursor = Cursor;
                list.ID     = ID;

                if (String.IsNullOrEmpty(list.ListID) && !String.IsNullOrEmpty(ListID))
                {
                    list.ListID = ListID;
                }

                list.PerPage    = PerPage;
                list.Page       = Page;
                list.ScreenName = ScreenName;
                list.SinceID    = SinceID;
            });

            return(lists.AsEnumerable().OfType <T>().ToList());
        }