本文整理汇总了C#中LinqToTwitter.List.Distinct方法的典型用法代码示例。如果您正苦于以下问题:C# List.Distinct方法的具体用法?C# List.Distinct怎么用?C# List.Distinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.List
的用法示例。
在下文中一共展示了List.Distinct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateStatus
public static void UpdateStatus()
{
Login();
OnStatusUpdating(EventArgs.Empty);
var status = new List<DGStatus>();
IOrderedEnumerable<DGStatus> newStatus = null;
try
{
for (int i = 0; i < Contexts.Count; i++)
{
var query = from t in Contexts[i].Status
where t.Type == StatusType.Home && t.CreatedAt >= s_lastStatusUpdating
select new DGStatus(t, Accounts[i]);
status.AddRange(query);
}
newStatus = status.Distinct(new StatusEqualityComparer()).OrderBy(s => s.CreatedAt);
}
catch (Exception ex)
{
OnStatusUpdateFailed(new StatusUpdateFailedEventArgs(ex));
return;
}
s_lastStatusUpdating = DateTime.UtcNow;
foreach (var s in newStatus)
{
OnStatusReceived(new StatusEventArgs(s));
}
OnStatusUpdated(new StatusUpdatedEventArgs(newStatus.ToArray()));
}
示例2: GetAllTweets
private List<Status> GetAllTweets(ulong sinceId = 0)
{
var allTweets = new List<Status>();
using (var twitter = new TwitterContext(Auth))
{
int lastCount = 199;
var oldestId = ulong.MaxValue;
while (lastCount > 1)
{
IQueryable<Status> statusTweets =
twitter.Status.Where(tweet => tweet.Type == StatusType.User
&& tweet.ScreenName == UserName
&& tweet.IncludeMyRetweet == true
&& tweet.ExcludeReplies == false
&& tweet.Count == 199);
if (oldestId != ulong.MaxValue)
statusTweets = statusTweets.Where(t => t.MaxID == oldestId);
if (sinceId != 0)
statusTweets = statusTweets.Where(t => t.SinceID == sinceId);
if (statusTweets != null)
{
var returned = statusTweets.ToList();
if (!returned.Any())
break;
lastCount = returned.Count();
oldestId = returned.Min(t => ulong.Parse(t.StatusID));
returned.RemoveAt(returned.Count - 1);
allTweets.AddRange(returned);
}
else
{
lastCount = 0;
}
}
}
return allTweets.Distinct().ToList();
}