本文整理汇总了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);
}
示例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;
}
示例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);
}
示例4: ListRequestProcessor_Handles_Actions
public void ListRequestProcessor_Handles_Actions()
{
var listReqProc = new ListRequestProcessor<List>();
Assert.IsAssignableFrom<IRequestProcessorWithAction<List>>(listReqProc);
}
示例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);
}
示例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);
}
示例7: ProcessResults_Handles_Subscriptions_Response
public void ProcessResults_Handles_Subscriptions_Response()
{
var listProc = new ListRequestProcessor<List> { Type = ListType.Subscriptions };
TestMultipleListsResponse(listProc);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例12: BuildUrl_Works_With_Json_Format_Data
public void BuildUrl_Works_With_Json_Format_Data()
{
var listReqProc = new ListRequestProcessor<List>();
Assert.IsAssignableFrom<IRequestProcessorWantsJson>(listReqProc);
}
示例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"));
}
示例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);
}
示例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);
}