本文整理汇总了C#中LinqToTwitter.List.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToList方法的具体用法?C# List.ToList怎么用?C# List.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.List
的用法示例。
在下文中一共展示了List.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTweetsOnlyFeedFromDB
// Gets Twitter Feed from azure database
public static ICollection<StatusTweet> GetTweetsOnlyFeedFromDB(string twitterAccountToDisplay)
{
var stList = new List<StatusTweet>();
try
{
using (var dbContext = new OnlyTweetContext())
{
dbContext.Database.Connection.Open();
//Get top 20 Status Tweets from the database
var query = (from t in dbContext.OnlyTweetDB
where t.ScreenName == twitterAccountToDisplay
orderby t.CreatedAt descending
select t).Take(20);
//Console.WriteLine("All Status Tweet in the database:");
foreach (var item in query)
{
var st = new StatusTweet();
//Console.WriteLine("{0}:\n{1}\n\t{2}\n\t{3}\n\", item.StatusID, item.ScreenName, item.Text, item.CreatedAt);
st.Text = item.Text;
st.CreatedAt = item.CreatedAt;
st.StatusID = item.StatusID;
st.ScreenName = item.ScreenName;
st.StringStatusID = item.StatusID.ToString();
switch (item.ScreenName)
{
case "Linq2Twitr": //Sample Username: https://twitter.com/Linq2Twitr
st.ProfileImageUrlHttps = "https://pbs.twimg.com/profile_images/378800000625948439/57f4351535721aeedc632745ceaacfea_400x400.png";
break;
default:
st.ProfileImageUrlHttps = "";
break;
}
stList.Add(st);
}
}
}
catch (Exception ex)
{
string innerMessage = (ex.InnerException != null) ? ex.InnerException.Message : String.Empty;
//Console.WriteLine("{0}\n{1}", ex.Message, innerMessage);
}
return stList.ToList();
}
示例2: GetFromAPI
public static List<Tweet> GetFromAPI() {
ulong sinceID = 83407830496968704;
List<Tweet> statusList = new List<Tweet>();
var twitterCtx = new TwitterContext(auth);
ulong maxID;
const int Count = 6000;
var userStatusResponse =
(from tweet in twitterCtx.Status
where tweet.Type == StatusType.User &&
tweet.ScreenName == Settings.Instance.username &&
tweet.SinceID == sinceID &&
tweet.Count == Count &&
tweet.Retweeted == false
select tweet)
.ToList();
foreach (var item in userStatusResponse)
{
statusList.Add((Tweet)item);
}
// first tweet processed on current query
maxID = userStatusResponse.Min(
status => ulong.Parse(status.StatusID.ToString())) - 1;
do
{
// now add sinceID and maxID
userStatusResponse =
(from tweet in twitterCtx.Status
where tweet.Type == StatusType.User &&
tweet.ScreenName == Settings.Instance.username &&
tweet.Count == Count &&
tweet.SinceID == sinceID &&
tweet.MaxID == maxID &&
tweet.Retweeted == false
select tweet)
.ToList();
if (userStatusResponse.Count > 0)
{
// first tweet processed on current query
maxID = userStatusResponse.Min(
status => ulong.Parse(status.StatusID.ToString())) - 1;
foreach (var item in userStatusResponse)
{
statusList.Add((Tweet)item);
}
}
}
while (userStatusResponse.Count != 0 && statusList.Count < Count);
return statusList.ToList();
}