本文整理汇总了C#中LinqToTwitter.List.First方法的典型用法代码示例。如果您正苦于以下问题:C# List.First方法的具体用法?C# List.First怎么用?C# List.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.List
的用法示例。
在下文中一共展示了List.First方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}