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


C# UserRequestProcessor类代码示例

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


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

示例1: UpdateAccountColors

        /// <summary>
        /// Update Twitter colors
        /// </summary>
        /// <remarks>
        /// The # character prefix is optional.  At least one color argument must be provided.
        /// </remarks>
        /// <param name="background">background color</param>
        /// <param name="text">text color</param>
        /// <param name="link">link color</param>
        /// <param name="sidebarFill">sidebar color</param>
        /// <param name="sidebarBorder">sidebar border color</param>
        /// <param name="includeEntities">Set to false to not include entities. (default: true)</param>
        /// <param name="skipStatus">Don't include status with response.</param>
        /// <param name="callback">Async Callback used in Silverlight queries</param>
        /// <returns>User info with new colors</returns>
        public static User UpdateAccountColors(this TwitterContext ctx, string background, string text, string link, string sidebarFill, string sidebarBorder, bool includeEntities, bool skipStatus, Action<TwitterAsyncResponse<User>> callback)
        {
            var accountUrl = ctx.BaseUrl + "account/update_profile_colors.json";

            if (string.IsNullOrEmpty(background) &&
                string.IsNullOrEmpty(text) &&
                string.IsNullOrEmpty(link) &&
                string.IsNullOrEmpty(sidebarFill) &&
                string.IsNullOrEmpty(sidebarBorder))
            {
                throw new ArgumentException("At least one of the colors (background, text, link, sidebarFill, or sidebarBorder) must be provided as arguments, but none are specified.", NoInputParam);
            }

            var reqProc = new UserRequestProcessor<User>();

            ITwitterExecute exec = ctx.TwitterExecutor;
            exec.AsyncCallback = callback;
            var resultsJson =
                exec.PostToTwitter(
                    accountUrl,
                    new Dictionary<string, string>
                    {
                        { "profile_background_color", string.IsNullOrEmpty(background) ? (string)null : background.TrimStart('#') },
                        { "profile_text_color", string.IsNullOrEmpty(text) ? (string)null : text.TrimStart('#') },
                        { "profile_link_color", string.IsNullOrEmpty(link) ? (string)null : link.TrimStart('#') },
                        { "profile_sidebar_fill_color", string.IsNullOrEmpty(sidebarFill) ? (string)null : sidebarFill.TrimStart('#') },
                        { "profile_sidebar_border_color", string.IsNullOrEmpty(sidebarBorder) ? (string)null : sidebarBorder.TrimStart('#') },
                        { "include_entities", includeEntities.ToString().ToLower() },
                        { "skip_status", skipStatus.ToString().ToLower() }
                    },
                    response => reqProc.ProcessActionResult(response, UserAction.SingleUser));

            User user = reqProc.ProcessActionResult(resultsJson, UserAction.SingleUser);
            return user;
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:50,代码来源:AccountExtensions.cs

示例2: UpdateAccountColorsAsync

        /// <summary>
        /// Update Twitter colors
        /// </summary>
        /// <remarks>
        /// The # character prefix is optional.  At least one color argument must be provided.
        /// </remarks>
        /// <param name="background">background color</param>
        /// <param name="text">text color</param>
        /// <param name="link">link color</param>
        /// <param name="sidebarFill">sidebar color</param>
        /// <param name="sidebarBorder">sidebar border color</param>
        /// <param name="includeEntities">Set to false to not include entities. (default: true)</param>
        /// <param name="skipStatus">Don't include status with response.</param>
        /// <returns>User info with new colors</returns>
        public async Task<User> UpdateAccountColorsAsync(string background, string text, string link, string sidebarFill, string sidebarBorder, bool includeEntities, bool skipStatus, CancellationToken cancelToken = default(CancellationToken))
        {
            var accountUrl = BaseUrl + "account/update_profile_colors.json";

            if (string.IsNullOrWhiteSpace(background) &&
                string.IsNullOrWhiteSpace(text) &&
                string.IsNullOrWhiteSpace(link) &&
                string.IsNullOrWhiteSpace(sidebarFill) &&
                string.IsNullOrWhiteSpace(sidebarBorder))
                throw new ArgumentException("At least one of the colors (background, text, link, sidebarFill, or sidebarBorder) must be provided as arguments, but none are specified.", NoInputParam);

            var reqProc = new UserRequestProcessor<User>();

            RawResult =
                await TwitterExecutor.PostToTwitterAsync<User>(
                    accountUrl,
                    new Dictionary<string, string>
                    {
                        { "profile_background_color", string.IsNullOrWhiteSpace(background) ? null : background.TrimStart('#') },
                        { "profile_text_color", string.IsNullOrWhiteSpace(text) ? null : text.TrimStart('#') },
                        { "profile_link_color", string.IsNullOrWhiteSpace(link) ? null : link.TrimStart('#') },
                        { "profile_sidebar_fill_color", string.IsNullOrWhiteSpace(sidebarFill) ? null : sidebarFill.TrimStart('#') },
                        { "profile_sidebar_border_color", string.IsNullOrWhiteSpace(sidebarBorder) ? null : sidebarBorder.TrimStart('#') },
                        { "include_entities", includeEntities.ToString().ToLower() },
                        { "skip_status", skipStatus.ToString().ToLower() }
                    },
                    cancelToken)
                    .ConfigureAwait(false);

            return reqProc.ProcessActionResult(RawResult, UserAction.SingleUser);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:45,代码来源:TwitterContextAccountCommands.cs

示例3: ReportSpam

        /// <summary>
        /// lets logged-in user report spam
        /// </summary>
        /// <param name="userID">user id of alleged spammer</param>
        /// <param name="screenName">screen name of alleged spammer</param>
        /// <param name="callback">Async Callback used in Silverlight queries</param>
        /// <returns>Alleged spammer user info</returns>
        public static User ReportSpam(this TwitterContext ctx, string userID, string screenName, Action<TwitterAsyncResponse<User>> callback)
        {
            if (string.IsNullOrEmpty(userID) &&
                string.IsNullOrEmpty(screenName))
            {
                throw new ArgumentException("Either userID or screenName is a required parameter.");
            }

            string reportSpamUrl = ctx.BaseUrl + "users/report_spam.json";

            var createParams = new Dictionary<string, string>
                {
                    { "user_id", userID },
                    { "screen_name", screenName }
                };

            var reqProc = new UserRequestProcessor<User>();

            ITwitterExecute exec = ctx.TwitterExecutor;
            exec.AsyncCallback = callback;
            var resultsJson =
                exec.PostToTwitter(
                    reportSpamUrl,
                    createParams,
                    response => reqProc.ProcessActionResult(response, UserAction.SingleUser));

            User user = reqProc.ProcessActionResult(resultsJson, UserAction.SingleUser);
            return user;
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:36,代码来源:ReportSpamExtensions.cs

示例4: MuteAsync

        async Task<User> MuteAsync(IDictionary<string, string> muteParams, CancellationToken cancelToken = default(CancellationToken))
        {
            var muteUrl = BaseUrl + "mutes/users/create.json";

            var reqProc = new UserRequestProcessor<User>();

            RawResult =
                await TwitterExecutor
                    .PostToTwitterAsync<User>(muteUrl, muteParams, cancelToken)
                    .ConfigureAwait(false);

            return reqProc.ProcessActionResult(RawResult, UserAction.SingleUser);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:13,代码来源:TwitterContextMuteCommands.cs

示例5: BuildUrl_BannerSize_Requires_NonEmpty_UserID

        public void BuildUrl_BannerSize_Requires_NonEmpty_UserID()
        {
            const string ExpectedParamName = "UserID";
            var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int)UserType.BannerSizes).ToString() },
                { "UserID", "" },
                //{ "ScreenName", "JoeMayo" }
            };

            var ex = L2TAssert.Throws<ArgumentNullException>(() => reqProc.BuildUrl(parameters));

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

示例6: BuildUrl_Constructs_BannerSize_Url

        public void BuildUrl_Constructs_BannerSize_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/users/profile_banner.json?user_id=15411837&screen_name=JoeMayo";
            var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int)UserType.BannerSizes).ToString() },
                { "UserID", "15411837" },
                { "ScreenName", "JoeMayo" }
            };

            Request req = reqProc.BuildUrl(parameters);

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

示例7: RemoveProfileBanner

        /// <summary>
        /// Removes banner from authenticated user's profile.
        /// </summary>
        /// <param name="callback">Async Callback.</param>
        /// <returns>Empty User instance.</returns>
        public static User RemoveProfileBanner(this TwitterContext ctx, Action<TwitterAsyncResponse<User>> callback)
        {
            var accountUrl = ctx.BaseUrl + "account/remove_profile_banner.json";

            var reqProc = new UserRequestProcessor<User>();

            ITwitterExecute exec = ctx.TwitterExecutor;
            exec.AsyncCallback = callback;
            var resultsJson =
                exec.PostToTwitter(
                    accountUrl,
                    new Dictionary<string, string>(),
                    response => reqProc.ProcessActionResult(response, UserAction.SingleUser));

            User user = reqProc.ProcessActionResult(resultsJson, UserAction.SingleUser);
            return user;
        }
开发者ID:CheyPMK,项目名称:linqtotwitter,代码行数:22,代码来源:AccountExtensions.cs

示例8: BuildUrl_Constructs_Search_Url

        public void BuildUrl_Constructs_Search_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/users/search.json?q=Joe%20Mayo&page=2&count=10&include_entities=true";
            var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int)UserType.Search).ToString() },
                { "Query", "Joe Mayo" },
                { "Page", "2" },
                { "Count", "10" },
                { "IncludeEntities", true.ToString() }
            };

            Request req = reqProc.BuildUrl(parameters);

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

示例9: ProcessResults_Parses_BannerSizes_Response

        public void ProcessResults_Parses_BannerSizes_Response()
        {
            var reqProc = new UserRequestProcessor<User> { Type = UserType.BannerSizes, BaseUrl = "http://api.twitter.com/1.1/" };

            List<User> userList = reqProc.ProcessResults(BannerSizesResponse);

            Assert.IsNotNull(userList);
            Assert.IsTrue(userList.Any());
            Assert.AreEqual(1, userList.Count);
            var user = userList.Single();
            Assert.IsNotNull(user);
            var bannerSizes = user.BannerSizes;
            Assert.IsNotNull(bannerSizes);
            Assert.AreEqual(6, bannerSizes.Count);
            var firstSize = bannerSizes.First();
            Assert.IsNotNull(firstSize);
            Assert.AreEqual("ipad_retina", firstSize.Label);
            Assert.AreEqual(1252, firstSize.Width);
            Assert.AreEqual(626, firstSize.Height);
            Assert.AreEqual("https://si0.twimg.com/profile_banners/16761255/1355801341/ipad_retina", firstSize.Url);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:21,代码来源:UserRequestProcessorTests.cs

示例10: ProcessResults_Parses_Category_Response

        public void ProcessResults_Parses_Category_Response()
        {
            var reqProc = new UserRequestProcessor<User> { Type = UserType.Category, BaseUrl = "http://api.twitter.com/1.1/" };

            List<User> userList = reqProc.ProcessResults(CategoryResponse);

            Assert.IsNotNull(userList);
            Assert.AreEqual(1, userList.Count);
            var user = userList.Single();
            Assert.IsNotNull(user);
            var categories = user.Categories;
            Assert.IsNotNull(categories);
            Assert.IsTrue(categories.Any());
            var category = categories.First();
            Assert.IsNotNull(category);
            Assert.AreEqual(64, category.Size);
            Assert.AreEqual("Funny", category.Name);
            Assert.AreEqual("funny", category.Slug);
            var users = category.Users;
            Assert.IsNotNull(users);
            Assert.IsTrue(users.Any());
            var catUser = users.First();
            Assert.IsNotNull(catUser);
            Assert.AreEqual("OMG TestMethods", catUser.Name);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:25,代码来源:UserRequestProcessorTests.cs

示例11: TestMultipleUserResponse

        void TestMultipleUserResponse(UserType type)
        {
            var reqProc = new UserRequestProcessor<User> { Type = type, BaseUrl = "http://api.twitter.com/1.1/" };

            List<User> userList = reqProc.ProcessResults(MultipleUserResponse);

            Assert.IsNotNull(userList);
            Assert.IsTrue(userList.Any());
            var user = userList.First();
            Assert.IsNotNull(user);
            Assert.AreEqual("bbccff", user.ProfileSidebarBorderColor);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:12,代码来源:UserRequestProcessorTests.cs

示例12: BuildUrl_Constructs_Contributors_Url

        public void BuildUrl_Constructs_Contributors_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/users/contributors.json?user_id=123&include_entities=true&skip_status=true";
            var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int)UserType.Contributors).ToString() },
                { "UserID", "123" },
                //{ "ScreenName", "JoeMayo" },
                { "IncludeEntities", true.ToString() },
                { "SkipStatus", true.ToString() }
            };

            Request req = reqProc.BuildUrl(parameters);

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

示例13: BuildUrl_Lookup_Throws_On_Both_UserID_And_ScreenName_Params

        public void BuildUrl_Lookup_Throws_On_Both_UserID_And_ScreenName_Params()
        {
            var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int)UserType.Lookup).ToString() },
                { "ScreenName", "JoeMayo,LinqToTweeter" },
                { "UserID", "1,2" }
            };

            var ex = L2TAssert.Throws<ArgumentException>(() => reqProc.BuildUrl(parameters));

            Assert.AreEqual("ScreenNameOrUserID", ex.ParamName);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:14,代码来源:UserRequestProcessorTests.cs

示例14: UserRequestProcessor_Works_With_Json_Format_Data

        public void UserRequestProcessor_Works_With_Json_Format_Data()
        {
            var reqProc = new UserRequestProcessor<User>();

            Assert.IsInstanceOfType(reqProc, typeof(IRequestProcessorWantsJson));
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:6,代码来源:UserRequestProcessorTests.cs

示例15: UpdateAccountBackgroundImage

        /// <summary>
        /// sends an image file to Twitter to replace background image
        /// </summary>
        /// <param name="image">full path to file, including file name</param>
        /// <param name="fileName">name to pass to Twitter for the file</param>
        /// <param name="imageType">type of image: must be one of jpg, gif, or png</param>
        /// <param name="tile">Tile image across background.</param>
        /// <param name="use">Whether to use uploaded background image or not</param>
        /// <param name="callback">Async Callback used in Silverlight queries</param>
        /// <param name="includeEntities">Set to false to not include entities. (default: true)</param>
        /// <param name="skipStatus">Don't include status with response.</param>
        /// <returns>User with new image info</returns>
        public static User UpdateAccountBackgroundImage(this TwitterContext ctx, byte[] image, string fileName, string imageType, bool tile, bool use, bool includeEntities, bool skipStatus, Action<TwitterAsyncResponse<User>> callback)
        {
            var accountUrl = ctx.BaseUrl + "account/update_profile_background_image.json";

            if (image == null || image.Length == 0)
            {
                throw new ArgumentException("image is required.", "image");
            }

            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("fileName is required.", "fileName");
            }

            if (string.IsNullOrEmpty(imageType))
            {
                throw new ArgumentException("imageType is required.", "imageType");
            }

            var parameters = new Dictionary<string, string>
            {
                { "include_entities", includeEntities.ToString().ToLower() },
                { "skip_status", skipStatus.ToString().ToLower() }
            };

            if (tile)
            {
                parameters.Add("tile", true.ToString().ToLower());
                parameters.Add("use", use.ToString().ToLower());
            }

            var reqProc = new UserRequestProcessor<User>();

            ITwitterExecute exec = ctx.TwitterExecutor;
            exec.AsyncCallback = callback;
            var resultsJson =
                exec.PostTwitterImage(accountUrl, parameters, image, fileName, imageType, reqProc);

            User user = reqProc.ProcessActionResult(resultsJson, UserAction.SingleUser);
            return user;
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:53,代码来源:AccountExtensions.cs


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