本文整理汇总了C#中LinqToTwitter.List类的典型用法代码示例。如果您正苦于以下问题:C# List类的具体用法?C# List怎么用?C# List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
List类属于LinqToTwitter命名空间,在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserTweets
public List<Status> UserTweets(string inUserName_)
{
List<Status> statusList = new List<Status>(from tweet in _twitterCtx.Status
where tweet.Type == StatusType.User &&
tweet.ScreenName == inUserName_ &&
tweet.Count == Cfg_Twitter.AMT_TWEET_QUERY &&
tweet.RetweetedStatus.StatusID == 0
select tweet);
ulong maxID = statusList[statusList.Count - 1].StatusID;
int prevCount = statusList.Count;
while (prevCount > 1)
{
if (statusList.Count > Cfg_Twitter.AMT_MAX_TWEETS)
break;
List<Status> tmp = (from tweet in _twitterCtx.Status
where tweet.Type == StatusType.User &&
tweet.ScreenName == inUserName_ &&
tweet.Count == Cfg_Twitter.AMT_TWEET_QUERY &&
tweet.RetweetedStatus.StatusID == 0 &&
tweet.MaxID == maxID
select tweet).ToList();
if (tmp.Count == 1)
break;
statusList.AddRange(tmp);
maxID = tmp[tmp.Count - 1].StatusID;
}
return statusList;
}
示例2: Load
private static IList<Status> Load(IQueryBuilder queryBuilder, ulong maxId, int count = 2000)
{
var statuses = new List<Status>();
//todo limit exception System.AggregateException, message: Rate limit exceeded - Please visit the LINQ to Twitter FAQ (at the HelpLink) for help on resolving this error.
var tweetQuery = queryBuilder.BuildTaskByMinId(maxId + 1).ToList();
statuses.AddRange(tweetQuery);
if (statuses.Count < 150)
{
return statuses;
}
while (statuses.Count < count)
{
tweetQuery = queryBuilder.BuildTaskByMinIdAndMaxId(maxId + 1, statuses[statuses.Count - 1].StatusID - 1).ToList();
statuses.AddRange(tweetQuery);
if (tweetQuery.Count < 150)
{
break;
}
}
return statuses;
}
示例3: CacheAccountList
private void CacheAccountList(List<Domain.Model.Account> accounts)
{
foreach(var item in accounts)
{
this.accountCache.Add(item.AccountId.ToString(), item, DateTimeOffset.Now.AddMinutes(20));
}
}
示例4: FenetrePrincipale
public FenetrePrincipale()
{
InitializeComponent();
listeTweets = new List<TweetControl>();
vScrollBar1.Maximum = nbTweetsToShow * ConfigurationManager.HEIGHT_TWEET_CONTROL - this.Height + ConfigurationManager.HEIGHT_TOOLBAR;
recupererTweets();
}
示例5: GetRecent200
private void GetRecent200()
{
var twitterContext = new TwitterContext(authorizedUser);
var tweets = from tweet in twitterContext.Status where tweet.Type == StatusType.Home && tweet.Count select tweet;
currentTweets = tweets.ToList();
}
示例6: RemoveSiteStreamUser
/// <summary>
/// Removes one or more users from a Site Stream
/// </summary>
/// <param name="ctx">Twitter Context</param>
/// <param name="userIDs">List of user IDs to remove from Site Stream</param>
/// <param name="streamID">ID of Site Stream to remove users from</param>
/// <param name="callback">Async Callback</param>
/// <returns>Control Stream with CommandResponse property for Twitter's response message</returns>
public static ControlStream RemoveSiteStreamUser(this TwitterContext ctx, List<ulong> userIDs, string streamID, Action<TwitterAsyncResponse<ControlStream>> callback)
{
if (string.IsNullOrEmpty(streamID)) throw new ArgumentNullException("streamID", "streamID is required.");
var newUrl = ctx.SiteStreamUrl + "site/c/" + streamID + "/remove_user.json";
string userIDString = string.Join(",", userIDs.Select(user => user.ToString()).ToArray());
var reqProc = new ControlStreamRequestProcessor<ControlStream>();
var twitExe = ctx.TwitterExecutor;
twitExe.AsyncCallback = callback;
var resultsJson =
twitExe.PostToTwitter(
newUrl,
new Dictionary<string, string>
{
{"user_id", userIDString}
},
response => reqProc.ProcessActionResult(response, ControlStreamType.Info));
ControlStream cs = reqProc.ProcessActionResult(resultsJson, ControlStreamType.Info);
return cs;
}
示例7: GetTweetsFor
public async Task<IEnumerable<TweetDto>> GetTweetsFor(IEnumerable<string> tweetsIds)
{
var tweetsIdsList = tweetsIds.Select(s => Convert.ToUInt64(s)).Materialize();
if (tweetsIdsList.IsEmpty())
{
return Enumerable.Empty<TweetDto>();
}
using (var twitterContext = CreateContext())
{
var results = new List<TweetDto>();
foreach (var tweetsId in tweetsIdsList)
{
var id = tweetsId;
var tweet = await
twitterContext.Status
.Where(status => status.Type == StatusType.Show && status.ID == id).FirstOrDefaultAsync();
if (tweet != null)
{
results.Add(BuildTweetDto(tweet));
}
}
return results;
}
}
示例8: Status
public JsonResult Status(string id)
{
Authorize();
string screenName = ViewBag.User;
IEnumerable<TweetViewModel> friendTweets = new List<TweetViewModel>();
if (string.IsNullOrEmpty(screenName))
{
return Json(friendTweets, JsonRequestBehavior.AllowGet);
}
twitterCtx = new TwitterContext(auth);
friendTweets =
(
from tweet in twitterCtx.Status
where tweet.Type == StatusType.Show &&
tweet.ID == id
select GetTweetViewModel(tweet))
.ToList();
if (friendTweets.Count() > 0)
return Json(friendTweets.ElementAt(0), JsonRequestBehavior.AllowGet);
else
return Json(new TweetViewModel { Tweet = "Requested Status Not Found" }, JsonRequestBehavior.AllowGet);
}
示例9: GetFollowers
private List<string> GetFollowers()
{
List<string> results = new List<string>();
var twitterContext = new TwitterContext(authorizedUser);
var temp = Enumerable.FirstOrDefault(from friend in twitterContext.Friendship
where friend.Type == FriendshipType.FollowersList &&
friend.ScreenName == "Bostato90" &&
friend.Count == 200
select friend);
if (temp != null)
{
temp.Users.ToList().ForEach(user => results.Add(user.Name));
while (temp != null && temp.CursorMovement.Next != 0)
{
temp = Enumerable.FirstOrDefault(from friend in twitterContext.Friendship
where friend.Type == FriendshipType.FollowersList &&
friend.ScreenName == "Bostato90" &&
friend.Count == 200 &&
friend.Cursor == temp.CursorMovement.Next
select friend);
if (temp != null) temp.Users.ToList().ForEach(user => results.Add(user.Name));
}
}
return results;
}
示例10: TweetGrid
public TweetGrid()
{
InitializeComponent();
panelDisabled.Dock = DockStyle.Fill;
splitContainer1.Dock = DockStyle.Fill;
Panes = new List<TweetPane>();
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var auth = new OAuth1Authenticator ("Ywun66NxYNMXgjzNRdIG12q4k",
"XQAQ5djSlMOiXfMhn5rl4fdPahqw0wNPW6nBS5I9aRCajbxMvJ",
new Uri("https://api.twitter.com/oauth/request_token"),
new Uri("https://api.twitter.com/oauth/authorize"),
new Uri("https://api.twitter.com/oauth/access_token"),
new Uri("http://mobile.twitter.com"));
auth.Completed += (sender, e) => {
DismissViewController (true, null);
if (e.IsAuthenticated) {
loggedInAccount = e.Account;
GetUserData ();
var mList = GetTwitterData();
mList.ContinueWith(async (Task<List<Status>> arg) =>{
myList = arg.Result;
//twitterHomeTableView.Source = new TwitterHomeSource(arg.Result.ToArray());
});
}
};
var ui = auth.GetUI();
PresentViewController(ui, true, null);
}
示例12: Followers
protected IList<string> Followers(TwitterContext twitterCtx, string user)
{
var result = new List<string>();
long cursor = -1;
do
{
var friendship = (from friend in twitterCtx.Friendship
where friend.Type == FriendshipType.FriendsList &&
friend.ScreenName == user &&
friend.Cursor == cursor
select friend)
.SingleOrDefaultAsync().Result;
if (friendship != null &&
friendship.Users != null &&
friendship.CursorMovement != null)
{
cursor = friendship.CursorMovement.Next;
}
if (friendship != null && friendship.Users != null)
result.AddRange(friendship.Users.Select(x => x.UserIDResponse));
} while (cursor != 0);
return result;
}
示例13: Main
static void Main(string[] args)
{
if (!EnsureSingleLoad())
{
Console.WriteLine("{0}: Another Instance Currently Runing", DateTime.Now);
return;
}
var streamMonitors = new List<DualStreamMonitor>();
UsersCollection.PrimaryUsers().AsParallel()
.ForAll(u =>
{
var streamMonitor = new DualStreamMonitor(u, Console.Out);
streamMonitor.Start();
lock (streamMonitors)
{
streamMonitors.Add(streamMonitor);
}
});
while (Console.ReadLine() != "exit") ;
streamMonitors.ForEach(s => s.Stop());
}
示例14: Relationship
public Relationship(JsonData relJson)
{
if (relJson == null) return;
ScreenName = relJson.GetValue<string>("screen_name");
Name = relJson.GetValue<string>("name");
RetweetsWanted = relJson.GetValue<bool>("want_retweets");
AllReplies = relJson.GetValue<bool>("all_replies");
MarkedSpam = relJson.GetValue<bool>("marked_spam");
ID = relJson.GetValue<ulong>("id");
Blocking = relJson.GetValue<bool>("blocking");
NotificationsEnabled = relJson.GetValue<bool>("notifications_enabled");
CanDm = relJson.GetValue<bool>("can_dm");
Muting = relJson.GetValue<bool>("muting", false);
var connections = relJson.GetValue<JsonData>("connections");
if (connections != null)
Connections =
(from JsonData connection in connections
select connection.ToString())
.ToList();
else
Connections = new List<string>();
FollowedBy =
relJson.GetValue<bool>("followed_by") ||
Connections.Contains("followed_by");
Following =
relJson.GetValue<bool>("following") ||
Connections.Contains("following");
}
示例15: 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);
}