本文整理汇总了C#中UserRequestProcessor类的典型用法代码示例。如果您正苦于以下问题:C# UserRequestProcessor类的具体用法?C# UserRequestProcessor怎么用?C# UserRequestProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserRequestProcessor类属于命名空间,在下文中一共展示了UserRequestProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetParameters_Handles_Input_Params
public void GetParameters_Handles_Input_Params()
{
var reqProc = new UserRequestProcessor<User>();
Expression<Func<User, bool>> expression =
user =>
user.Type == UserType.Show &&
user.UserID == 10 &&
user.UserIdList == "1,2" &&
user.ScreenName == "JoeMayo" &&
user.ScreenNameList == "JoeMayo,Linq2Tweeter" &&
user.Cursor == 10819235 &&
user.Slug == "twitter" &&
user.Query == "Joe Mayo" &&
user.Page == 2 &&
user.Count == 10 &&
user.Lang == "it" &&
user.IncludeEntities == true &&
user.SkipStatus == true &&
user.ImageSize == ProfileImageSize.Mini;
var lambdaExpression = expression as LambdaExpression;
var queryParams = reqProc.GetParameters(lambdaExpression);
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("Type", ((int)UserType.Show).ToString())));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("UserID", "10")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("UserIdList", "1,2")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("ScreenName", "JoeMayo")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("ScreenNameList", "JoeMayo,Linq2Tweeter")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("Cursor", "10819235")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("Slug", "twitter")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("Query", "Joe Mayo")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("Page", "2")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("Count", "10")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("Lang", "it")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("IncludeEntities", "True")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("SkipStatus", "True")));
Assert.IsTrue(
queryParams.Contains(
new KeyValuePair<string, string>("ImageSize", ((int)ProfileImageSize.Mini).ToString())));
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:68,代码来源:UserRequestProcessorTests.cs
示例17: ProcessResults_Retains_Original_Input_Parameters
public void ProcessResults_Retains_Original_Input_Parameters()
{
var reqProc = new UserRequestProcessor<User>
{
Type = UserType.Show,
BaseUrl = "https://api.twitter.com/1.1/",
UserID = 123ul,
UserIdList = "1,2",
ScreenName = "JoeMayo",
ScreenNameList = "JoeMayo,Linq2Tweeter",
Page = 1,
Count = 10,
Cursor = 456,
Slug = "myslug",
Query = "myquery",
Lang = "en-US",
SkipStatus = true,
ImageSize = ProfileImageSize.Bigger,
IncludeEntities = true
};
List<User> users = reqProc.ProcessResults(SingleUserResponse);
Assert.IsNotNull(users);
Assert.AreEqual(1, users.Count);
var user = users.First();
Assert.AreEqual(123ul, user.UserID);
Assert.AreEqual("1,2", user.UserIdList);
Assert.AreEqual("JoeMayo", user.ScreenName);
Assert.AreEqual("JoeMayo,Linq2Tweeter", user.ScreenNameList);
Assert.AreEqual(1, user.Page);
Assert.AreEqual(10, user.Count);
Assert.AreEqual(456L, user.Cursor);
Assert.AreEqual("myslug", user.Slug);
Assert.AreEqual("myquery", user.Query);
Assert.AreEqual("en-US", user.Lang);
Assert.IsTrue(user.SkipStatus);
Assert.AreEqual(ProfileImageSize.Bigger, user.ImageSize);
Assert.IsTrue(user.IncludeEntities);
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:40,代码来源:UserRequestProcessorTests.cs
示例18: BuildUrl_Constructs_Lookup_Url
public void BuildUrl_Constructs_Lookup_Url()
{
const string ExpectedUrl = "https://api.twitter.com/1.1/users/lookup.json?user_id=1%2C2&include_entities=true";
var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
var parameters = new Dictionary<string, string>
{
{ "Type", ((int)UserType.Lookup).ToString() },
{ "UserIdList", "1,2" },
{ "IncludeEntities", true.ToString() }
};
Request req = reqProc.BuildUrl(parameters);
Assert.AreEqual(ExpectedUrl, req.FullUrl);
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:15,代码来源:UserRequestProcessorTests.cs
示例19: BuildUrl_Throws_On_Null_Params
public void BuildUrl_Throws_On_Null_Params()
{
var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
var ex = L2TAssert.Throws<ArgumentException>(() => reqProc.BuildUrl(null));
Assert.AreEqual<string>("Type", ex.ParamName);
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:8,代码来源:UserRequestProcessorTests.cs
示例20: BuildUrl_Throws_On_Missing_Type
public void BuildUrl_Throws_On_Missing_Type()
{
var reqProc = new UserRequestProcessor<User> { BaseUrl = "https://api.twitter.com/1.1/" };
var parameters = new Dictionary<string, string> { };
var ex = L2TAssert.Throws<ArgumentException>(() => reqProc.BuildUrl(parameters));
Assert.AreEqual<string>("Type", ex.ParamName);
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:9,代码来源:UserRequestProcessorTests.cs
注:本文中的UserRequestProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论