• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ListRequestProcessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: BuildShowUrl_Returns_Url

        public void BuildShowUrl_Returns_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/show.json?slug=test&owner_id=123&owner_screen_name=JoeMayo&list_id=456";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Show).ToString() },
                { "OwnerID", "123" },
                { "OwnerScreenName", "JoeMayo" },
                { "Slug", "test" },
                { "ListID", "456" }
            };

            Request req = listReqProc.BuildUrl(parameters);

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


示例17: BuildStatusesUrl_Includes_False_Parameters

        public void BuildStatusesUrl_Includes_False_Parameters()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/statuses.json?owner_id=123&owner_screen_name=JoeMayo&slug=test&list_id=456&since_id=789&max_id=234&count=25&per_page=25&page=3&trim_user=false&include_entities=false&include_rts=false";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Statuses).ToString() },
                { "OwnerID", "123" },
                { "OwnerScreenName", "JoeMayo" },
                { "Slug", "test" },
                { "ListID", "456" },
                { "SinceID", "789" },
                { "MaxID", "234" },
                { "Count", "25" },
                { "Page", "3" },
                { "TrimUser", "false" },
                { "IncludeEntities", "false" },
                { "IncludeRetweets", "false" }
            };

            Request req = listReqProc.BuildUrl(parameters);

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


示例18: ProcessResults_Retains_Original_Input_Parameters

        public void ProcessResults_Retains_Original_Input_Parameters()
        {
            var listProc = new ListRequestProcessor<List> 
            { 
                Type = ListType.Show,
                UserID = "123",
                ScreenName = "JoeMayo",
                Cursor = "456",
                ListID = "789",
                Slug = "MyList",
                OwnerID = "123",
                OwnerScreenName = "JoeMayo",
                MaxID = 150,
                Count = 50,
                Page = 1,
                SinceID = 25,
                TrimUser = true,
                IncludeEntities = true,
                IncludeRetweets = true,
                FilterToOwnedLists = true,
                SkipStatus = true,
                Reverse = true
            };

            var listsResponse = listProc.ProcessResults(SingleListResponse);

            var lists = listsResponse as IList<List>;
            Assert.NotNull(lists);
            Assert.Single(lists);
            var list = lists.Single();
            Assert.Equal(ListType.Show, list.Type);
            Assert.Equal("123", list.UserID);
            Assert.Equal("JoeMayo", list.ScreenName);
            Assert.Equal("456", list.Cursor);
            Assert.Equal("789", list.ListID);
            Assert.Equal("MyList", list.Slug);
            Assert.Equal("123", list.OwnerID);
            Assert.Equal("JoeMayo", list.OwnerScreenName);
            Assert.Equal(150ul, list.MaxID);
            Assert.Equal(50, list.Count);
            Assert.Equal(1, list.Page);
            Assert.Equal(25ul, list.SinceID);
            Assert.True(list.TrimUser);
            Assert.True(list.IncludeEntities);
            Assert.True(list.IncludeRetweets);
            Assert.True(list.FilterToOwnedLists);
            Assert.True(list.SkipStatus);
            Assert.True(list.Reverse);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:49,代码来源:ListRequestProcessorTests.cs


示例19: BuildUrl_Returns_SubscribersUrl

        public void BuildUrl_Returns_SubscribersUrl()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/subscribers.json?owner_id=123&owner_screen_name=JoeMayo&slug=test&list_id=456&cursor=789&include_entities=true&skip_status=true";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Subscribers).ToString() },
                { "Slug", "test" },
                { "OwnerID", "123" },
                { "OwnerScreenName", "JoeMayo" },
                { "ListID", "456" },
                { "Cursor", "789" },
                { "IncludeEntities", true.ToString() },
                { "SkipStatus", true.ToString() }
            };

            Request req = listReqProc.BuildUrl(parameters);

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


示例20: BuildUrl_Creates_Lists_Url

        public void BuildUrl_Creates_Lists_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/list.json?screen_name=JoeMayo";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters =
                new Dictionary<string, string>
                {
                    { "Type", ((int)ListType.Lists).ToString() },
                    { "ScreenName", "JoeMayo" }
                };

            Request req = listReqProc.BuildUrl(parameters);

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ListResult类代码示例发布时间:2022-05-24
下一篇:
C# ListObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap