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


C# List.OrderByDescending方法代码示例

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


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

示例1: GetTwitterDialogWithFriend

		private async Task<IDialog> GetTwitterDialogWithFriend(DataIUser user, DataIUser friend)
		{
			IDialog dialog = null;
			IUser userInDialog = null;
			IList<IMessage> messages = new List<IMessage>();
 
			try
			{
				TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

				var receivedMessages = await
						(from dm in context.DirectMessage
						 where dm.Type == DirectMessageType.SentTo
						 select dm).OrderByDescending(x => x.CreatedAt)
						.ToListAsync();

				var sentMessages = await
						(from dm in context.DirectMessage
						 where dm.Type == DirectMessageType.SentBy
						 select dm).OrderByDescending(x => x.CreatedAt)
						.ToListAsync();

				foreach (var message in receivedMessages)
				{
					if (message.SenderID.ToString() == friend.Uid)
					{
						userInDialog = new User() { FirstName = message.Sender.ScreenNameResponse };
						messages.Add(new DataMessage() { Content = message.Text, Sender = userInDialog, DateMessage = message.CreatedAt.ToString() });
					}
				}

				foreach (var message in sentMessages)
				{
					if (message.RecipientID.ToString() == friend.Uid)
					{
						userInDialog = new User() { FirstName = message.Sender.ScreenNameResponse };
						messages.Add(new DataMessage() { Content = message.Text, Sender = userInDialog, DateMessage = message.CreatedAt.ToString() });
					}
				}

				messages = messages.OrderByDescending(x => x.DateMessage).ToList();

				dialog = new XamarinSocialApp.UI.Data.Implementations.Entities.Databases.Dialog(user, messages);
			}
			catch (Exception)
			{
			}

			return dialog;
		}
开发者ID:deadean,项目名称:SocialNetworkApi,代码行数:50,代码来源:OAuthService.cs

示例2: 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


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