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


C# List.Count方法代码示例

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


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

示例1: SizableImages

 public SizableImages(List<int> counts)
 {
     for (int i = 0; i < counts.Count(); i++)
     {
         tweetsTotalCount = counts.Sum();
         SizableImage simage = new SizableImage();
         simage.id = i;
         simage.size = 1 + (int)(MAX_SIZE * (double)counts[i] / tweetsTotalCount);
         simage.positionX = 0;
         simage.positionY = 0;
         images.Add(simage);
     }
     images.Sort((x, y) => (-x.size).CompareTo(-y.size));
 }
开发者ID:litoshko,项目名称:Twitter-Collage,代码行数:14,代码来源:HomeController.cs

示例2: ResetLastAccessed

 public void ResetLastAccessed(List<Objects.Option> options, int defaultPollingInterval)
 {
     if (options.Count(x => x.Active) > 0)
     {
         DateTime currentDate = DateTime.Now.ToUniversalTime();
         DateTime defaultLastCheckedDate = currentDate.AddMilliseconds(-defaultPollingInterval);
         foreach (Objects.Option option in options.Where(x => x.Active))
         {
             switch ((TwitterOptionId)option.OptionId)
             {
                 case TwitterOptionId.TweetCount:
                     option.LastAccessed = currentDate.AddMinutes(-option.Numerics[0]);
                     break;
                 default:
                     option.LastAccessed = defaultLastCheckedDate;
                     break;
             }
         }
     }
 }
开发者ID:runtime1point0,项目名称:Fritz-Notifier,代码行数:20,代码来源:TwitterNotifier.cs

示例3: TestForNotifications

        public List<Objects.Notification> TestForNotifications(List<Objects.Option> options)
        {
            var notifications = new List<Objects.Notification>(options.Count);
            //return notifications;
            if (options.Count(x => x.Active) > 0)
            {
                using (var ctx = new LinqToTwitter.TwitterContext(auth))
                {

                    try
                    {
                        //Account account = accounts.SingleOrDefault();
                        Account account = ctx.Account.Single(acct => acct.Type == AccountType.VerifyCredentials && acct.SkipStatus == true);
                        //var account = twitterCtx.Account
                        //    .Where(t => t.Type == AccountType.VerifyCredentials)
                        //    .FirstOrDefault(t => t.SkipStatus == true);
                        User user = account.User;
                        Status tweet = user.Status ?? new Status();
                        Console.WriteLine("User (#" + user.Identifier.ID
                                            + "): " + user.Identifier.ScreenName
                                            + "\nTweet: " + tweet.Text
                                            + "\nTweet ID: " + tweet.StatusID + "\n");

                        Console.WriteLine("Account credentials are verified.");
                    }
                    catch (System.Net.WebException wex)
                    {
                        Console.WriteLine("Twitter did not recognize the credentials. Response from Twitter: " + wex.Message);
                    }

                    //var testMessageNotification = new FritzNotifier.Objects.Notification(this.NotificationApplication, this.WebsiteOrProgramAddress, 0, "Test sender" + " sent message " + "message 1", "New message from " + "Test sender", DateTime.Now);
                    //var testSimpleMessage = new FritzNotifier.Objects.Notification(this.NotificationApplication, this.WebsiteOrProgramAddress, 0, "simple notification", null, DateTime.Now);

                    //notifications.Add(testMessageNotification);
                    //notifications.Add(testSimpleMessage);
                    //return notifications;

                    try
                    {
                        DateTime currentDateLocal = DateTime.Now;
                        DateTime currentDate = currentDateLocal.ToUniversalTime();
                        foreach (Objects.Option option in options.Where(x => x.Active))
                        {
                            switch ((TwitterOptionId)option.OptionId)
                            {
                                case TwitterOptionId.TweetCount:
                                    // if enough time has passed since we last accessed this
                                    if ((currentDate - option.LastAccessed).TotalMinutes > option.Numerics[0])
                                    {
                                        int tweetCount =
                                            (from tweet in ctx.Status
                                             where tweet.Type == StatusType.Home &&
                                             tweet.CreatedAt > option.LastAccessed
                                             select tweet).Count();

                                        if (tweetCount > 0)
                                        {
                                            var newTweetCountNotification = new FritzNotifier.Objects.Notification(this.NotificationApplication, this.WebsiteOrProgramAddress, 0, tweetCount.ToString() + " new tweets.", tweetCount.ToString() + " new tweets.", currentDateLocal);
                                            option.LastAccessed = currentDate;
                                            notifications.Add(newTweetCountNotification);
                                        }
                                    }
                                    break;
                                case TwitterOptionId.DirectMessage:
                                    var directMsgs =
                                        (from dm in ctx.DirectMessage
                                         where dm.Type == DirectMessageType.SentTo &&
                                         dm.CreatedAt > option.LastAccessed
                                         select dm).ToList();
                                    foreach (var directMsg in directMsgs)
                                    {
                                        // handle appropriately
                                        var newDirectMessageNotification = new FritzNotifier.Objects.Notification(this.NotificationApplication, this.WebsiteOrProgramAddress, 0, directMsg.Sender.Name + " sent message " + directMsg.Text, "New message from " + directMsg.Sender.Name, currentDateLocal);
                                        notifications.Add(newDirectMessageNotification);
                                        option.LastAccessed = currentDate;
                                    }

                                    break;
                            }
                        }
                    }
                    catch (System.Net.WebException wex)
                    {
                        Console.WriteLine("Twitter did not recognize the credentials. Response from Twitter: " + wex.Message);
                    }
                }
            }

            return notifications;
        }
开发者ID:runtime1point0,项目名称:Fritz-Notifier,代码行数:90,代码来源:TwitterNotifier.cs

示例4: Status

 public JsonResult Status(string id)
 {
     Authorize();
     string screenName = ViewBag.User;
     IEnumerable<TweetViewModel> friendTweets = new List<TweetViewModel>();
     if (string.IsNullOrEmpty(screenName))
     {
         return Json(friendTweets, JsonRequestBehavior.AllowGet);
     }
     twitterCtx = new TwitterContext(auth);
     friendTweets =
         (from tweet in twitterCtx.Status
          where tweet.Type == StatusType.Show &&
                tweet.ID == id
          select GetTweetViewModel(tweet))
         .ToList();
     if (friendTweets.Count() > 0)
         return Json(friendTweets.ElementAt(0), JsonRequestBehavior.AllowGet);
     else
         return Json(new TweetViewModel { Tweet = "Requested Status Not Found" }, JsonRequestBehavior.AllowGet);
 }
开发者ID:JamesBender,项目名称:angularjs-mvc-twitter-client,代码行数:21,代码来源:HomeController.cs

示例5: Get

        public static List<Tweet> Get(string screenname, ulong maxStatusID)
        {
            int fetchMultiplier = int.Parse(
                !string.IsNullOrEmpty(ConfigurationManager.AppSettings["FetchMultiplier"]) ?
                    ConfigurationManager.AppSettings["FetchMultiplier"] : "10");

            List<string> screenNames = new List<string>();
            screenNames.AddRange(TwitterModel.Instance.GetRelevantScreenNames(screenname));

            List<Tweet> tweets = new List<Tweet>();
            screenNames.ForEach(name =>
            {
                var t = Repository<Tweet>.Instance.Query(name + TwitterModel.TWEETS);
                if (t != null) tweets.AddRange(t);
            });
            if (tweets != null)
                tweets = tweets.OrderByDescending(t => t.Status.CreatedAt).ToList();
            if (tweets == null ||
                tweets.Count() < 5 ||
                !tweets.Select(t => t.Status.CreatedAt).IsWithinAverageRecurrenceInterval(multiplier: fetchMultiplier))
            {

                var lastStatusID = (tweets != null && tweets.Count() > 0) ? ulong.Parse(tweets.First().Status.StatusID) : 0;
                var user = UsersCollection.Single(screenname) ?? UsersCollection.PrimaryUser();
                if (user.CanAuthorize)
                {
                    try
                    {
                        Expression<Func<Status, bool>> where;
                        if (maxStatusID > 0 && lastStatusID > 0)
                            where = (s => s.MaxID == maxStatusID &&
                                s.SinceID == lastStatusID &&
                                s.ScreenName == screenname &&
                                s.IncludeEntities == true &&
                                s.Type == StatusType.User &&
                                s.Count == 50);
                        else if (lastStatusID > 0)
                            where = (s => s.SinceID == lastStatusID &&
                                s.ScreenName == screenname &&
                                s.IncludeEntities == true &&
                                s.Type == StatusType.Home &&
                                s.Count == 200);
                        else
                            where = (s => s.ScreenName == screenname &&
                                s.IncludeEntities == true &&
                                s.Type == StatusType.Home &&
                                s.Count == 200);

                        var statuses = TwitterModel.Instance.GetAuthorizedTwitterContext(user.TwitterScreenName)
                            .Status
                            .Where(where)
                            .ToList();

                        List<Tweet> results;

                        if (statuses != null && statuses.Count > 0)
                            results = statuses.Select(s => new Tweet(s)).ToList();
                        else
                            results = null;

                        return results;
                    }
                    catch { return null; }
                }
            }
            return null;
        }
开发者ID:rickyn,项目名称:postworthy,代码行数:67,代码来源:StatusTimeline.cs

示例6: SaveTweets

        public static void SaveTweets(string filepath, List<Tweet> saveTweets) {

            using (System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.Create))
            {

                using (System.IO.TextWriter writer = new System.IO.StreamWriter(fs, System.Text.Encoding.UTF8))
                {

                    XmlSerializer xs = new XmlSerializer(typeof(List<Tweet>));
                    xs.Serialize(writer, saveTweets);

                }

            }

            SavedExports.Load();

            SavedExports.Instance.ListOfExports.Add(new SavedExports.GestTweetExport()
            {
                dateOfExport = DateTime.Now,
                DirectoryName = filepath,
                NumOfTweets = saveTweets.Count(),
                typeExport = SavedExports.TypeOfExport.API
            });

            SavedExports.Save();

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


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