Example #1
0
        /// <summary>
        /// transforms Twitter response into List of Status
        /// </summary>
        /// <param name="responseJson">Twitter response</param>
        /// <returns>List of Status</returns>
        public virtual List <T> ProcessResults(string responseJson)
        {
            if (string.IsNullOrWhiteSpace(responseJson))
            {
                return(new List <T>());
            }

            JsonData statusJson = JsonMapper.ToObject(responseJson);

            List <Status> statusList;

            switch (Type)
            {
            case StatusType.Show:
                statusList = new List <Status> {
                    new Status(statusJson)
                };
                break;

            case StatusType.Home:
            case StatusType.Lookup:
            case StatusType.Mentions:
            case StatusType.RetweetsOfMe:
            case StatusType.Retweets:
            case StatusType.User:
                statusList =
                    (from JsonData status in statusJson
                     select new Status(status))
                    .ToList();
                break;

            case StatusType.Retweeters:
                statusList = new List <Status>
                {
                    new Status
                    {
                        Users =
                            (from JsonData id in statusJson.GetValue <JsonData>("ids")
                             select(ulong) id)
                            .ToList(),
                        CursorMovement = new Cursors(statusJson)
                    }
                };
                break;

            case StatusType.Oembed:
                statusList = new List <Status>
                {
                    new Status
                    {
                        EmbeddedStatus = new EmbeddedStatus(statusJson)
                    }
                };
                break;

            default:
                statusList = new List <Status>();
                break;
            }

            foreach (var status in statusList)
            {
                status.Type                      = Type;
                status.ID                        = ID;
                status.UserID                    = UserID;
                status.ScreenName                = ScreenName;
                status.SinceID                   = SinceID;
                status.MaxID                     = MaxID;
                status.Count                     = Count;
                status.Cursor                    = Cursor;
                status.IncludeRetweets           = IncludeRetweets;
                status.ExcludeReplies            = ExcludeReplies;
                status.IncludeEntities           = IncludeEntities;
                status.IncludeUserEntities       = IncludeUserEntities;
                status.TrimUser                  = TrimUser;
                status.IncludeContributorDetails = IncludeContributorDetails;
                status.IncludeMyRetweet          = IncludeMyRetweet;
                status.IncludeAltText            = IncludeAltText;
                status.OEmbedAlign               = OEmbedAlign;
                status.OEmbedHideMedia           = OEmbedHideMedia;
                status.OEmbedHideThread          = OEmbedHideThread;
                status.OEmbedMaxWidth            = OEmbedMaxWidth;
                status.OEmbedOmitScript          = OEmbedOmitScript;
                status.OEmbedRelated             = OEmbedRelated;
                status.OEmbedUrl                 = OEmbedUrl;
                status.OEmbedLanguage            = OEmbedLanguage;
                status.TweetIDs                  = TweetIDs;
                status.Map                       = Map;
                status.TweetMode                 = TweetMode;
            }

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