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


C# ListRequestProcessor类代码示例

本文整理汇总了C#中ListRequestProcessor的典型用法代码示例。如果您正苦于以下问题:C# ListRequestProcessor类的具体用法?C# ListRequestProcessor怎么用?C# ListRequestProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ListRequestProcessor类属于命名空间,在下文中一共展示了ListRequestProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateListAsync

        /// <summary>
        /// Modifies an existing list.
        /// </summary>
        /// <param name="listID">ID of list</param>
        /// <param name="slug">name of list</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="mode">public or private</param>
        /// <param name="description">list description</param>
        /// <returns>List info for modified list</returns>
        public async Task<List> UpdateListAsync(ulong listID, string slug, string name, ulong ownerID, string ownerScreenName, string mode, string description, CancellationToken cancelToken = default(CancellationToken))
        {
            if (listID == 0 && string.IsNullOrWhiteSpace(slug))
                throw new ArgumentException("Either listID or slug is required.", ListIDOrSlugParam);

            if (!string.IsNullOrWhiteSpace(slug) && ownerID == 0 && string.IsNullOrWhiteSpace(ownerScreenName))
                throw new ArgumentException("If you specify a Slug, you must also specify either OwnerID or OwnerScreenName.", OwnerIDOrOwnerScreenNameParam);

            var updateListUrl = BaseUrl + "lists/update.json";

            var reqProc = new ListRequestProcessor<List>();

            RawResult =
                await TwitterExecutor.PostToTwitterAsync<List>(
                    updateListUrl,
                    new Dictionary<string, string>
                    {
                        { "list_id", listID.ToString() },
                        { "slug", slug },
                        { "owner_id", ownerID.ToString() },
                        { "owner_screen_name", ownerScreenName },
                        { "mode", mode },
                        { "description", description },
                        { "name", name }
                    },
                    cancelToken)
                    .ConfigureAwait(false);

            return reqProc.ProcessActionResult(RawResult, ListAction.Update);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:40,代码来源:TwitterContextListCommands.cs

示例2: CreateList

        /// <summary>
        /// Creates a new list
        /// </summary>
        /// <param name="listName">name of list</param>
        /// <param name="mode">public or private</param>
        /// <param name="description">list description</param>
        /// <param name="callback">Async Callback used in Silverlight queries</param>
        /// <returns>List info for new list</returns>
        public static List CreateList(this TwitterContext ctx, string listName, string mode, string description, Action<TwitterAsyncResponse<List>> callback)
        {
            if (string.IsNullOrEmpty(listName))
            {
                throw new ArgumentException("listName is required.", "listName");
            }

            var createUrl = ctx.BaseUrl + "lists/create.json";

            var reqProc = new ListRequestProcessor<List>();

            ITwitterExecute exec = ctx.TwitterExecutor;
            exec.AsyncCallback = callback;
            var resultsJson =
                exec.PostToTwitter(
                    createUrl,
                    new Dictionary<string, string>
                    {
                        { "name", listName },
                        { "mode", mode },
                        { "description", description }
                    },
                    response => reqProc.ProcessActionResult(response, ListAction.Create));

            List results = reqProc.ProcessActionResult(resultsJson, ListAction.Create);
            return results;
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:35,代码来源:ListExtensions.cs

示例3: CreateListAsync

        /// <summary>
        /// Creates a new list.
        /// </summary>
        /// <param name="listName">name of list</param>
        /// <param name="mode">public or private</param>
        /// <param name="description">list description</param>
        /// <returns>List info for new list</returns>
        public async Task<List> CreateListAsync(string listName, string mode, string description, CancellationToken cancelToken = default(CancellationToken))
        {
            if (string.IsNullOrWhiteSpace(listName))
                throw new ArgumentException("listName is required.", "listName");

            var createUrl = BaseUrl + "lists/create.json";

            var reqProc = new ListRequestProcessor<List>();

            RawResult =
                await TwitterExecutor.PostToTwitterAsync<List>(
                    createUrl,
                    new Dictionary<string, string>
                    {
                        { "name", listName },
                        { "mode", mode },
                        { "description", description }
                    },
                    cancelToken)
                    .ConfigureAwait(false);

            return reqProc.ProcessActionResult(RawResult, ListAction.Create);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:30,代码来源:TwitterContextListCommands.cs

示例4: ListRequestProcessor_Handles_Actions

        public void ListRequestProcessor_Handles_Actions()
        {
            var listReqProc = new ListRequestProcessor<List>();

            Assert.IsAssignableFrom<IRequestProcessorWithAction<List>>(listReqProc);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:6,代码来源:ListExtensionsTests.cs

示例5: TestSingleUserResponse

        void TestSingleUserResponse(ListRequestProcessor<List> listProc)
        {
            var listsResponse = listProc.ProcessResults(SingleUserResponse);

            var lists = listsResponse as IList<List>;
            Assert.NotNull(lists);
            Assert.Single(lists);
            var users = lists.Single().Users;
            Assert.NotNull(users);
            Assert.Single(users);
            Assert.Equal("LINQ to Tweeter Test", users.Single().Name);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:12,代码来源:ListRequestProcessorTests.cs

示例6: TestMultipleUsersResponse

        void TestMultipleUsersResponse(ListRequestProcessor<List> listProc)
        {
            var listsResponse = listProc.ProcessResults(MultipleUsersResponse);

            var lists = listsResponse as IList<List>;
            Assert.NotNull(lists);
            Assert.Single(lists);
            var list = lists.Single();
            var users = list.Users;
            Assert.NotNull(users);
            Assert.Equal(3, users.Count);
            Assert.Equal("LINQ to Tweeter Test", users.First().Name);
            var cursor = list.CursorMovement;
            Assert.NotNull(cursor);
            Assert.Equal("1352721896474871923", cursor.Next);
            Assert.Equal("7", cursor.Previous);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:17,代码来源:ListRequestProcessorTests.cs

示例7: ProcessResults_Handles_Subscriptions_Response

        public void ProcessResults_Handles_Subscriptions_Response()
        {
            var listProc = new ListRequestProcessor<List> { Type = ListType.Subscriptions };

            TestMultipleListsResponse(listProc);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:6,代码来源:ListRequestProcessorTests.cs

示例8: BuildUrl_Returns_Ownerships_Url

        public void BuildUrl_Returns_Ownerships_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/ownerships.json?user_id=789&screen_name=JoeMayo&count=10&cursor=1";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Ownerships).ToString() },
                { "UserID", "789" },
                { "ScreenName", "JoeMayo" },
                { "Count", "10" },
                { "Cursor", "1" }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:17,代码来源:ListRequestProcessorTests.cs

示例9: BuildIsSubscriberUrl_Requires_UserID_Or_ScreenName

        public void BuildIsSubscriberUrl_Requires_UserID_Or_ScreenName()
        {
            const string ExpectedParamName = "UserIdOrScreenName";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.IsSubscribed).ToString()},
                { "Slug", "test" },
                {"OwnerID", "123"},
            };

            var ex = Assert.Throws<ArgumentException>(() => listReqProc.BuildUrl(parameters));

            Assert.Equal(ExpectedParamName, ex.ParamName);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:15,代码来源:ListRequestProcessorTests.cs

示例10: BuildSubscribersUrl_Requires_Non_Null_And_Not_Empty_ListID_Or_Slug

        public void BuildSubscribersUrl_Requires_Non_Null_And_Not_Empty_ListID_Or_Slug()
        {
            const string ExpectedParamName = "ListIdOrSlug";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Subscribers).ToString()},
                { "ListID", "" },
                { "Slug", null }
                //{"OwnerID", "123"},
            };

            var ex = Assert.Throws<ArgumentException>(() => listReqProc.BuildUrl(parameters));

            Assert.Equal(ExpectedParamName, ex.ParamName);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:16,代码来源:ListRequestProcessorTests.cs

示例11: ProcessResults_Returns_Empty_Collection_When_Empty_Results

        public void ProcessResults_Returns_Empty_Collection_When_Empty_Results()
        {
            var listReqProc = new ListRequestProcessor<List>();

            var results = listReqProc.ProcessResults(string.Empty);

            Assert.Equal(0, results.Count);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:8,代码来源:ListRequestProcessorTests.cs

示例12: BuildUrl_Works_With_Json_Format_Data

        public void BuildUrl_Works_With_Json_Format_Data()
        {
            var listReqProc = new ListRequestProcessor<List>();

            Assert.IsAssignableFrom<IRequestProcessorWantsJson>(listReqProc);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:6,代码来源:ListRequestProcessorTests.cs

示例13: ProcessResults_Handles_Statuses_Response

        public void ProcessResults_Handles_Statuses_Response()
        {
            var listProc = new ListRequestProcessor<List> { Type = ListType.Statuses };

            var listsResponse = listProc.ProcessResults(ListStatusesResponse);

            var lists = listsResponse as IList<List>;
            Assert.NotNull(lists);
            Assert.Single(lists);
            var statuses = lists.Single().Statuses;
            Assert.NotNull(statuses);
            Assert.Equal(4, statuses.Count);
            Assert.True(statuses.First().Text.StartsWith("so using this approach"));
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:14,代码来源:ListRequestProcessorTests.cs

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

示例15: UnsubscribeFromListAsync

        /// <summary>
        /// Removes a user as a list subscriber.
        /// </summary>
        /// <param name="listID">ID of list.</param>
        /// <param name="slug">Name of list to remove from.</param>
        /// <param name="ownerID">ID of user 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>
        public async Task<List> UnsubscribeFromListAsync(ulong listID, string slug, 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 (!string.IsNullOrWhiteSpace(slug) && ownerID == 0 && string.IsNullOrWhiteSpace(ownerScreenName))
                throw new ArgumentException("If using slug, you must also provide either ownerID or ownerScreenName.", OwnerIDOrOwnerScreenNameParam);

            var unsubscribeUrl = BaseUrl + "lists/subscribers/destroy.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 (ownerID != 0)
                parameters.Add("owner_id", ownerID.ToString());
            if (!string.IsNullOrWhiteSpace(ownerScreenName))
                parameters.Add("owner_screen_name", ownerScreenName);

            RawResult =
                await TwitterExecutor.PostToTwitterAsync<List>(unsubscribeUrl, parameters, cancelToken).ConfigureAwait(false);

            return reqProc.ProcessActionResult(RawResult, ListAction.Unsubscribe);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:36,代码来源:TwitterContextListCommands.cs


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