当前位置: 首页>>代码示例>>C#>>正文


C# List.ToArray方法代码示例

本文整理汇总了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();
			}
		}
开发者ID:emoacht,项目名称:CSharpPlay,代码行数:40,代码来源:TweetWorker.cs

示例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;
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:46,代码来源:ListExtensions.cs

示例3: GetstringfromList

 public string GetstringfromList(List<string> myList)
 {
     return string.Join(" ", myList.ToArray());
 }
开发者ID:HarryMcCarney,项目名称:Tweet-Tagger,代码行数:4,代码来源:Twitter.cs


注:本文中的LinqToTwitter.List.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。