本文整理汇总了C#中LinqToTwitter.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.List
的用法示例。
在下文中一共展示了List.ToArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetrieveMentionsAsync
public async Task<MentionPack[]> RetrieveMentionsAsync(TimeSpan windowDuration)
{
var mentioneeScreenName = _selfScreenName;
var mentioneeScreenNameWithAt = $"@{_selfScreenName}";
using (var context = new TwitterContext(_selfAuthorizer))
{
var packs = new List<MentionPack>();
var mentions = await
(from tweet in context.Status
where (tweet.Type == StatusType.Mentions)
&& (tweet.ScreenName == mentioneeScreenName)
&& ((tweet.User != null) && (tweet.User.ScreenNameResponse != mentioneeScreenName)) // Mentioner
&& (new DateTimeOffset(tweet.CreatedAt) >= DateTimeOffset.Now.Add(-windowDuration))
select tweet)
.ToListAsync();
if (mentions != null)
{
foreach (var mention in mentions)
{
var mentionContent = WebUtility.HtmlDecode(mention.Text)?.TrimStartCombined('.');
if (string.IsNullOrEmpty(mentionContent) ||
!mentionContent.StartsWith(mentioneeScreenNameWithAt, StringComparison.Ordinal))
continue;
mentionContent = mentionContent.Substring(mentioneeScreenNameWithAt.Length).Trim();
packs.Add(new MentionPack(
tweetId: mention.StatusID,
tweetTime: new DateTimeOffset(mention.CreatedAt),
content: mentionContent,
mentionerScreenName: mention.User.ScreenNameResponse,
mentioneeScreenName: mentioneeScreenName));
}
}
return packs.ToArray();
}
}
示例2: AddMemberRangeToList
/// <summary>
/// Adds a list of users to a list.
/// </summary>
/// <param name="listID">ID of List.</param>
/// <param name="slug">List name.</param>
/// <param name="ownerID">ID of user who owns the list.</param>
/// <param name="ownerScreenName">Screen name of user who owns the list.</param>
/// <param name="userIDs">List of user IDs to be list members. (max 100)</param>
/// <param name="screenNames">List of user screen names to be list members. (max 100)</param>
/// <param name="callback">Async Callback used in Silverlight queries</param>
/// <returns>List info for list members added to.</returns>
static List AddMemberRangeToList(this TwitterContext ctx, string listID, string slug, string ownerID, string ownerScreenName, IEnumerable<ulong> userIDs, List<string> screenNames, Action<TwitterAsyncResponse<List>> callback)
{
if (string.IsNullOrEmpty(listID) && string.IsNullOrEmpty(slug))
{
throw new ArgumentException("Either listID or slug is required.", ListIDOrSlugParam);
}
if (!string.IsNullOrEmpty(slug) && string.IsNullOrEmpty(ownerID) && string.IsNullOrEmpty(ownerScreenName))
{
throw new ArgumentException("If using slug, you must also provide either ownerID or ownerScreenName.", OwnerIDOrOwnerScreenNameParam);
}
var addMemberRangeUrl = ctx.BaseUrl + "lists/members/create_all.json";
var reqProc = new ListRequestProcessor<List>();
ITwitterExecute exec = ctx.TwitterExecutor;
exec.AsyncCallback = callback;
var resultsJson =
exec.PostToTwitter(
addMemberRangeUrl,
new Dictionary<string, string>
{
{ "list_id", listID },
{ "slug", slug },
{ "owner_id", ownerID },
{ "owner_screen_name", ownerScreenName },
{ "user_id", userIDs == null ? null : string.Join(",", userIDs.Select(id => id.ToString(CultureInfo.InvariantCulture)).ToArray()) },
{ "screen_name", screenNames == null ? null : string.Join(",", screenNames.ToArray()) }
},
response => reqProc.ProcessActionResult(response, ListAction.AddMember));
List results = reqProc.ProcessActionResult(resultsJson, ListAction.AddMember);
return results;
}
示例3: GetstringfromList
public string GetstringfromList(List<string> myList)
{
return string.Join(" ", myList.ToArray());
}