本文整理汇总了C#中LinqToTwitter.List.Min方法的典型用法代码示例。如果您正苦于以下问题:C# List.Min方法的具体用法?C# List.Min怎么用?C# List.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.List
的用法示例。
在下文中一共展示了List.Min方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowFavoritesAsync
static async Task ShowFavoritesAsync(TwitterContext twitterCtx)
{
const int PerQueryFavCount = 200;
// set from a value that you previously saved
ulong sinceID = 1;
var favsResponse =
await
(from fav in twitterCtx.Favorites
where fav.Type == FavoritesType.Favorites &&
fav.Count == PerQueryFavCount
select fav)
.ToListAsync();
if (favsResponse == null)
{
Console.WriteLine("No favorites returned from Twitter.");
return;
}
var favList = new List<Favorites>(favsResponse);
// first tweet processed on current query
ulong maxID = favList.Min(fav => fav.StatusID) - 1;
do
{
favsResponse =
await
(from fav in twitterCtx.Favorites
where fav.Type == FavoritesType.Favorites &&
fav.Count == PerQueryFavCount &&
fav.SinceID == sinceID &&
fav.MaxID == maxID
select fav)
.ToListAsync();
if (favsResponse == null || favsResponse.Count == 0) break;
// reset first tweet to avoid re-querying the
// same list you just received
maxID = favsResponse.Min(fav => fav.StatusID) - 1;
favList.AddRange(favsResponse);
} while (favsResponse.Count > 0);
favList.ForEach(fav =>
{
if (fav != null && fav.User != null)
Console.WriteLine(
"Name: {0}, Tweet: {1}",
fav.User.ScreenNameResponse, fav.Text);
});
// save this in your db for this user so you can set
// sinceID accurately the next time you do a query
// and avoid querying the same tweets again.
ulong newSinceID = favList.Max(fav => fav.SinceID);
}