/// <summary> /// The async implementation of <see cref="DeleteTags"/> /// </summary> public static void DeleteTagsAsync(AsyncCallback<TagIDs> callback, params long[] tagIDs) { ValidateArgument(tagIDs, "tagIDs"); var count = tagIDs.Length; if (count == 0) throw new AMicroblogException(LocalErrorCode.ArgumentNotProvided, "Tag IDs not provided."); var tagBuilder = new StringBuilder(); for (int i = 0; i < tagIDs.Length; i++) { tagBuilder.Append(tagIDs[i]); if (i < count - 1) tagBuilder.Append(","); } var requester = new OAuthHttpDelete(APIUri.DeleteTags); requester.Params.Add("ids", tagBuilder.ToString()); requester.RequestAsync(delegate(AsyncCallResult<string> result) { var preprocess = new Func<string, string>(delegate(string response) { return response.Replace("tags>", "tagids>"); }); ProcessAsyncCallbackResponse<TagIDs>(result, callback, preprocess); }); }
/// <summary> /// The async implementation of <see cref="UnfollowTrend"/> /// </summary> public static void UnfollowTrendAsync(AsyncCallback<bool> callback, long trendID) { var requester = new OAuthHttpDelete(APIUri.UnfollowTrend); requester.Params.Add("trend_id", trendID.ToString(InvariantCulture)); requester.RequestAsync(delegate(AsyncCallResult<string> result) { Func<string, bool> customProcess = delegate(string response) { var match = Regex.Match(response, @"<result>(\w+?)</result>", RegexOptions.IgnoreCase); var isUnfollowed = bool.Parse(match.Groups[1].Value); return isUnfollowed; }; ProcessAsyncCallbackResponseCustom(result, callback, customProcess); }); }
/// <summary> /// The async implementation of <see cref="Unblock"/> /// </summary> public static void UnblockAsync(AsyncCallback<UserInfo> callback, long? userID = null, string screenName = null) { var requester = new OAuthHttpDelete(APIUri.Unblock); if (userID.HasValue) requester.Params.Add("user_id", userID.Value.ToString(InvariantCulture)); if (!string.IsNullOrEmpty(screenName)) requester.Params.Add("screen_name", RFC3986Encoder.UrlEncode(screenName)); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="IsBlocked"/> /// </summary> public static void IsBlockedAsync(AsyncCallback<bool> callback, long? userID = null, string screenName = null) { var requester = new OAuthHttpDelete(APIUri.IsBlocked); if (userID.HasValue) requester.Params.Add("user_id", userID.Value.ToString(InvariantCulture)); if (!string.IsNullOrEmpty(screenName)) requester.Params.Add("screen_name", screenName); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponseCustom(result, callback, response => response.Contains("true")); }); }
/// <summary> /// The async implementation of <see cref="DeleteTag"/> /// </summary> public static void DeleteTagAsync(VoidAsyncCallback callback, long tagID) { var requester = new OAuthHttpDelete(APIUri.DeleteTag); requester.Params.Add("tag_id", tagID.ToString(InvariantCulture)); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackVoidResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="DeleteStatus"/> /// </summary> public static void DeleteStatusAsync(AsyncCallback<StatusInfo> callback, long statusID) { ValidateArgument(statusID, "statusID"); var requester = new OAuthHttpDelete(string.Format("{0}/{1}.xml", APIUri.DeleteStatus, statusID)); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="DeleteMultipleFromFavorite"/> /// </summary> public static void DeleteMultipleFromFavoriteAsync(AsyncCallback<Statuses> callback, params long[] statusIDs) { ValidateArgument(statusIDs, "statusIDs"); var count = statusIDs.Length; if (count == 0) throw new AMicroblogException(LocalErrorCode.ArgumentNotProvided, "Status IDs not provided."); var tagBuilder = new StringBuilder(); for (int i = 0; i < statusIDs.Length; i++) { tagBuilder.Append(statusIDs[i]); if (i < count - 1) tagBuilder.Append(","); } var requester = new OAuthHttpDelete(APIUri.DeleteMultipleFromFavorite); requester.Params.Add("ids", tagBuilder.ToString()); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="DeleteFromFavorite"/> /// </summary> public static void DeleteFromFavoriteAsync(AsyncCallback<StatusInfo> callback, long statusID) { var requester = new OAuthHttpDelete(string.Format("{0}/{1}.xml", APIUri.DeleteFromFavorite, statusID)); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="DeleteDirectMessages"/> /// </summary> public static void DeleteDirectMessagesAsync(AsyncCallback<DirectMessages> callback, params long[] directMessageIDs) { ValidateArgument(directMessageIDs, "directMessageID"); var count = directMessageIDs.Length; if (0 == count) throw new AMicroblogException(LocalErrorCode.ArgumentNotProvided, "Direct message IDs not provided."); var sBuilder = new StringBuilder(); for (int i = 0; i < directMessageIDs.Length; i++) { sBuilder.Append(directMessageIDs[i]); if (i < count - 1) sBuilder.Append(","); } var requester = new OAuthHttpDelete(APIUri.DeleteDirectMessages); requester.Params.Add("ids", sBuilder.ToString()); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }