本文整理汇总了C#中LinqToTwitter.List.Select方法的典型用法代码示例。如果您正苦于以下问题:C# List.Select方法的具体用法?C# List.Select怎么用?C# List.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.List
的用法示例。
在下文中一共展示了List.Select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: CreateCollage
public static Bitmap CreateCollage(List<User> users, int height, int width)
{
const double minSliceRatio = 0.35;
var threshold = users.Max(x => x.StatusesCount) / 20;
var elements = users
.Select(x => new Element<User>
{
Object = x,
Value = x.StatusesCount < threshold ? threshold : x.StatusesCount
})
.OrderByDescending(x => x.Value)
.ToList();
var slice = Treemap.GetSlice(elements, 1, minSliceRatio);
var rectangles = Treemap.GetRectangles(slice, width, height).ToList();
return DrawTreemap(rectangles, width, height);
}
示例3: RemoveSiteStreamUserAsync
/// <summary>
/// Removes one or more users from a Site Stream
/// </summary>
/// <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>
/// <returns>Control Stream with CommandResponse property for Twitter's response message</returns>
public async Task<ControlStream> RemoveSiteStreamUserAsync(List<ulong> userIDs, string streamID, CancellationToken cancelToken = default(CancellationToken))
{
if (string.IsNullOrWhiteSpace(streamID)) throw new ArgumentNullException("streamID", "streamID is required.");
var newUrl = SiteStreamUrl + "site/c/" + streamID + "/remove_user.json";
string userIDString = string.Join(",", userIDs.Select(user => user.ToString()).ToArray());
var reqProc = new ControlStreamRequestProcessor<ControlStream>();
var resultsJson =
await TwitterExecutor.PostToTwitterAsync<ControlStream>(
newUrl,
new Dictionary<string, string>
{
{"user_id", userIDString}
},
cancelToken)
.ConfigureAwait(false);
return reqProc.ProcessActionResult(resultsJson, ControlStreamType.Info);
}
示例4: DeleteMemberRangeFromListAsync
/// <summary>
/// Deletes membership for a comma-separated list of users.
/// </summary>
/// <param name="listID">ID of list.</param>
/// <param name="slug">Name of list to remove from.</param>
/// <param name="userIds">List of user IDs of users to remove from list membership.</param>
/// <param name="screenNames">List of screen names of users to remove from list membership.</param>
/// <param name="ownerID">ID of users who owns the list.</param>
/// <param name="ownerScreenName">Screen name of user who owns the list.</param>
/// <returns>List info for list subscription removed from</returns>
async Task<List> DeleteMemberRangeFromListAsync(ulong listID, string slug, List<ulong> userIDs, List<string> screenNames, ulong ownerID, string ownerScreenName, CancellationToken cancelToken = default(CancellationToken))
{
if (listID == 0 && string.IsNullOrWhiteSpace(slug))
throw new ArgumentException("Either listID or slug is required.", ListIDOrSlugParam);
if (listID == 0 && !string.IsNullOrWhiteSpace(slug) &&
ownerID == 0 && string.IsNullOrWhiteSpace(ownerScreenName))
throw new ArgumentException("If using slug, you must also provide either ownerID or ownerScreenName.", OwnerIDOrOwnerScreenNameParam);
if ((userIDs != null && userIDs.Count > 100) ||
(screenNames != null && screenNames.Count > 100))
throw new ArgumentException("You can only remove 100 members at a Time.", "userIDs");
var destroyAllUrl = BaseUrl + "lists/members/destroy_all.json";
var reqProc = new ListRequestProcessor<List>();
var parameters = new Dictionary<string, string>();
if (listID != 0)
parameters.Add("list_id", listID.ToString());
if (!string.IsNullOrWhiteSpace(slug))
parameters.Add("slug", slug);
if (userIDs != null && userIDs.Any())
parameters.Add("user_id", string.Join(",", userIDs.Select(id => id.ToString(CultureInfo.InvariantCulture)).ToArray()));
if (screenNames != null && screenNames.Any())
parameters.Add("screen_name", string.Join(",", screenNames));
if (ownerID != 0)
parameters.Add("owner_id", ownerID.ToString());
if (!string.IsNullOrWhiteSpace(ownerScreenName))
parameters.Add("owner_screen_name", ownerScreenName);
RawResult =
await TwitterExecutor.PostToTwitterAsync<List>(destroyAllUrl, parameters, cancelToken).ConfigureAwait(false);
return reqProc.ProcessActionResult(RawResult, ListAction.DestroyAll);
}
示例5: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
var auth = new WebAuthorizer
{
Credentials = new SessionStateCredentials()
};
var twitterCtx = new TwitterContext(auth);
/////////////////////////////////
///// get this user's tweets ////
string name = TextBoxUser.Text; //twt.getScreenName(); //"mishari11";
/////////////////////////////////
/////////////////////////////////
////// show token and secret and Screen Name in page
Label1.Text = twt.getToken();
Label2.Text = twt.getTokenSecret();
Label4.Text = twt.getTwitterID();
//// 111111111111111111111111111111111111111111111111111111111
/// first API requst before the while loop to get the "maxID"
var statusTweets =
from tweet in twitterCtx.Status
where tweet.Type == StatusType.User
&& tweet.ScreenName == name /// get this user's tweets
&& tweet.Count == 200 /// number of tweets to retrieve in single requst // max is 200
&& tweet.ExcludeReplies == true /// do not show replies
&& tweet.IncludeMyRetweet == false /// do not show my retweet
&& tweet.IncludeRetweets == false /// do not show other pepole retweet
select tweet;
////// (ahmed) this is for the userID for each tweet i do not if you need it or not (you wrote it)
//var test3 = statusTweets.Select(tweet => tweet.UserID).ToArray();
//List<String> test10 = new List<string>();
//test10.AddRange(test3);
////// store tweets and RTConut in var
var tmepTweet = statusTweets.Select(tweet => tweet.Text).ToArray();
var tempRetweetCount = statusTweets.Select(tweet => tweet.RetweetCount).ToArray();
///// add tweet and RTCount to temp lists
List<String> lstTempTweet = new List<string>();
lstTempTweet.AddRange(tmepTweet);
List<int> lstTempRTCount = new List<int>();
lstTempRTCount.AddRange(tempRetweetCount);
//// to store the Status that retrieve each time from the API (Status conteant evry thing about the tweet "text" "RTCount" etc..)
var statusList = new List<Status>(); ;
//// 22222222222222222222222222222222222222222222222222222
//// the rest of APT requsts (up to 3200 tweets including replies and retweets)
int intcall = 1; // counter for number of requst to twitter API
while (statusTweets.Count() != 0)
{
//// get the ID of last tweet retrieved -1
ulong maxID = statusTweets.Min(status => ulong.Parse(status.StatusID)) - 1;
statusTweets =
from tweet in twitterCtx.Status
where tweet.Type == StatusType.User
&& tweet.ScreenName == name /// get this user's tweets
&& tweet.Count == 200 /// number of tweets to retrieve in single requst // max is 200
&& tweet.ExcludeReplies == true /// do not show replies
&& tweet.IncludeMyRetweet == false /// do not show my retweet
&& tweet.IncludeRetweets == false /// do not show other pepole retweet
&& tweet.MaxID == maxID /// retrieve before this ID
select tweet;
//// store the Status and add 1 to requst counter
statusList.AddRange(statusTweets);
intcall++;
} /// end while loop
////// store tweets and RTConut in var
tmepTweet = statusList.Select(tweet => tweet.Text).ToArray();
tempRetweetCount = statusList.Select(tweet => tweet.RetweetCount).ToArray();
///// add tweet and RTCount to temp lists
lstTempTweet.AddRange(tmepTweet);
lstTempRTCount.AddRange(tempRetweetCount);
//// add tweet and RTCount twtUser object "twt"
twt.setLstTwts(lstTempTweet);
twt.setLstTwtsRT(lstTempRTCount);
///////////// print all tweets ///////////////////////////////
List<String> tempTWT = new List<string>();
tempTWT = twt.getarrTwts();
List<int> tempRT = new List<int>();
tempRT = twt.getarrTwtsRT();
for (int k = 0; k < tempTWT.Count; k++)
{
classes.DBConnection NewConnection = new classes.DBConnection();
//.........这里部分代码省略.........
示例6: 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;
}