当前位置: 首页>>代码示例>>C#>>正文


C# List.ToList方法代码示例

本文整理汇总了C#中LinqToTwitter.List.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToList方法的具体用法?C# List.ToList怎么用?C# List.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinqToTwitter.List的用法示例。


在下文中一共展示了List.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTweetsOnlyFeedFromDB

        // Gets Twitter Feed from azure database
        public static ICollection<StatusTweet> GetTweetsOnlyFeedFromDB(string twitterAccountToDisplay)
        {
            var stList = new List<StatusTweet>();
            try
            {
                using (var dbContext = new OnlyTweetContext())
                {
                    dbContext.Database.Connection.Open();
                    //Get top 20 Status Tweets from the database 
                    var query = (from t in dbContext.OnlyTweetDB
                                 where t.ScreenName == twitterAccountToDisplay
                                 orderby t.CreatedAt descending
                                 select t).Take(20);

                    //Console.WriteLine("All Status Tweet in the database:");
                    foreach (var item in query)
                    {
                        var st = new StatusTweet();
                        //Console.WriteLine("{0}:\n{1}\n\t{2}\n\t{3}\n\", item.StatusID, item.ScreenName, item.Text, item.CreatedAt);

                        st.Text = item.Text;
                        st.CreatedAt = item.CreatedAt;
                        st.StatusID = item.StatusID;
                        st.ScreenName = item.ScreenName;
                        st.StringStatusID = item.StatusID.ToString();

                        switch (item.ScreenName)
                        {
                            case "Linq2Twitr": //Sample Username: https://twitter.com/Linq2Twitr
                                st.ProfileImageUrlHttps = "https://pbs.twimg.com/profile_images/378800000625948439/57f4351535721aeedc632745ceaacfea_400x400.png";
                                break;
                            default:
                                st.ProfileImageUrlHttps = "";
                                break;
                        }

                        stList.Add(st);
                    }

                }
            }
            catch (Exception ex)
            {
                string innerMessage = (ex.InnerException != null) ? ex.InnerException.Message : String.Empty;
                //Console.WriteLine("{0}\n{1}", ex.Message, innerMessage);
            }

            return stList.ToList();
        }
开发者ID:SravanBogu,项目名称:CustomSharePointSolutions,代码行数:50,代码来源:TwDbHelper.cs

示例2: GetFromAPI

        public static List<Tweet> GetFromAPI() {

            ulong sinceID = 83407830496968704;
            List<Tweet> statusList = new List<Tweet>();

            var twitterCtx = new TwitterContext(auth);

            ulong maxID;
            const int Count = 6000;

            var userStatusResponse =
                (from tweet in twitterCtx.Status
                 where tweet.Type == StatusType.User &&
                   tweet.ScreenName == Settings.Instance.username &&
                   tweet.SinceID == sinceID &&
                   tweet.Count == Count &&
                   tweet.Retweeted == false
                 select tweet)
                .ToList();

            foreach (var item in userStatusResponse)
            {
                statusList.Add((Tweet)item);
            }

            // first tweet processed on current query
            maxID = userStatusResponse.Min(
                status => ulong.Parse(status.StatusID.ToString())) - 1;

            do
            {
                // now add sinceID and maxID
                userStatusResponse =
                    (from tweet in twitterCtx.Status
                     where tweet.Type == StatusType.User &&
                           tweet.ScreenName == Settings.Instance.username &&
                           tweet.Count == Count &&
                           tweet.SinceID == sinceID &&
                           tweet.MaxID == maxID &&
                           tweet.Retweeted == false
                     select tweet)
                    .ToList();

                if (userStatusResponse.Count > 0)
                {
                    // first tweet processed on current query
                    maxID = userStatusResponse.Min(
                        status => ulong.Parse(status.StatusID.ToString())) - 1;

                    foreach (var item in userStatusResponse)
                    {
                        statusList.Add((Tweet)item);
                    }
                }
            }
            while (userStatusResponse.Count != 0 && statusList.Count < Count);

            return statusList.ToList();


        }
开发者ID:Ruekov,项目名称:gestTweet,代码行数:61,代码来源:TweetAPI.cs


注:本文中的LinqToTwitter.List.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。