本文整理汇总了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;
}
示例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;
}