Permalink
Browse files

Changed CommandPerformer so that it isn't generic, but the PerformAct…

…ion method is.

Fixes 91
  • Loading branch information...
digitallyborn
digitallyborn committed Jun 14, 2011
1 parent 7109595 commit ec096fd40a4a64eacd9fa202f4a74f21cd585478
Showing with 387 additions and 146 deletions.
  1. +16 −2 Twitterizer2.Async/TwitterListAsync.cs
  2. +13 −0 Twitterizer2.TestCases/CoreTests.cs
  3. +4 −4 Twitterizer2.TestCases/TwitterListTests.cs
  4. +4 −2 Twitterizer2.nunit
  5. +3 −8 Twitterizer2/Core/CommandPerformer.cs
  6. +4 −4 Twitterizer2/Methods/Account/TwitterAccount.cs
  7. +1 −1 Twitterizer2/Methods/Account/TwitterRateLimitStatus.cs
  8. +8 −8 Twitterizer2/Methods/Block/TwitterBlock.cs
  9. +6 −6 Twitterizer2/Methods/DirectMessage/TwitterDirectMessage.cs
  10. +3 −3 Twitterizer2/Methods/Favorites/TwitterFavorite.cs
  11. +15 −12 Twitterizer2/Methods/Friendship/TwitterFriendship.cs
  12. +1 −1 Twitterizer2/Methods/Friendship/TwitterRelationship.cs
  13. +1 −1 Twitterizer2/Methods/Geo/TwitterPlace.cs
  14. +2 −7 Twitterizer2/Methods/List/CreateListCommand.cs
  15. +41 −0 Twitterizer2/Methods/List/CreateListMembershipCommand.cs
  16. +31 −10 Twitterizer2/Methods/List/GetListCommand.cs
  17. +3 −0 Twitterizer2/Methods/List/GetListMembersOptions.cs
  18. +2 −15 Twitterizer2/Methods/List/GetListsCommand.cs
  19. +138 −20 Twitterizer2/Methods/List/TwitterList.cs
  20. +3 −8 Twitterizer2/Methods/List/UpdateListCommand.cs
  21. +7 −4 Twitterizer2/Methods/Notification/TwitterNotification.cs
  22. +3 −3 Twitterizer2/Methods/SavedSearches/TwitterSavedSearch.cs
  23. +1 −1 Twitterizer2/Methods/Search/TwitterSearch.cs
  24. +5 −2 Twitterizer2/Methods/Spam/TwitterSpam.cs
  25. +10 −8 Twitterizer2/Methods/Timeline/TwitterTimeline.cs
  26. +1 −1 Twitterizer2/Methods/Trends/TwitterTrend.cs
  27. +7 −7 Twitterizer2/Methods/Tweets/TwitterStatus.cs
  28. +6 −6 Twitterizer2/Methods/User/TwitterUser.cs
  29. +2 −2 Twitterizer2/Methods/User/TwitterUserCategory.cs
  30. +42 −0 Twitterizer2/OAuth/OAuthTokens.cs
  31. +1 −0 Twitterizer2/Twitterizer2.csproj
  32. +3 −0 Twitterizer2lite/Twitterizer2lite.csproj
@@ -124,13 +124,27 @@ public static IAsyncResult Delete(OAuthTokens tokens, string username, string li
/// <param name="timeout">The timeout.</param>
/// <param name="function">The function.</param>
/// <returns></returns>
+ [Obsolete("TwitterListAsync.GetList() has been replaced with TwitterListAsync.Show()")]
public static IAsyncResult GetList(OAuthTokens tokens, string username, string listIdOrSlug, OptionalProperties options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterList>> function)
{
- Func<OAuthTokens, string, string, OptionalProperties, TwitterResponse<TwitterList>> methodToCall = TwitterList.GetList;
+ return Show(tokens, listIdOrSlug, options, timeout, function);
+ }
+
+ /// <summary>
+ /// Show the specified list. Private lists will only be shown if the authenticated user owns the specified list.
+ /// </summary>
+ /// <param name="tokens">The tokens.</param>
+ /// <param name="listIdOrSlug">The list id or slug.</param>
+ /// <param name="options">The options.</param>
+ /// <param name="timeout">The timeout.</param>
+ /// <param name="function">The function.</param>
+ /// <returns></returns>
+ public static IAsyncResult Show(OAuthTokens tokens, string listIdOrSlug, OptionalProperties options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterList>> function)
+ {
+ Func<OAuthTokens, string, OptionalProperties, TwitterResponse<TwitterList>> methodToCall = TwitterList.Show;
return methodToCall.BeginInvoke(
tokens,
- username,
listIdOrSlug,
options,
result =>
@@ -80,5 +80,18 @@ public static void SSL()
Assert.That(timeline.RequestUrl.StartsWith("https://"));
Assert.That(user.RequestUrl.StartsWith("https://"));
}
+
+ [Test]
+ [Category("Distribution")]
+ public static void CheckAssemblySignature()
+ {
+Assembly asm = Assembly.GetAssembly(typeof(TwitterUser));
+if (asm != null)
+{
+ AssemblyName asmName = asm.GetName();
+ byte[] key = asmName.GetPublicKey();
+ Assert.That(key.Length > 0);
+}
+ }
}
}
@@ -12,9 +12,9 @@ public class TwitterListTests
[Test]
[Category("ReadOnly")]
[Category("REST")]
- public void GetList()
+ public void Show()
{
- TwitterList list = TwitterList.GetList(Configuration.GetTokens(), userName, listName, null).ResponseObject;
+ TwitterList list = TwitterList.Show(Configuration.GetTokens(), listName, null).ResponseObject;
Assert.IsNotNull(list);
}
@@ -38,7 +38,7 @@ public void GetMembers()
{
OAuthTokens tokens = Configuration.GetTokens();
- TwitterResponse<TwitterList> list = TwitterList.GetList(tokens, "ghc", "ghc10-attendees");
+ TwitterResponse<TwitterList> list = TwitterList.Show(tokens, "ghc10-attendees");
TwitterResponse<TwitterUserCollection> usersInTheList = TwitterList.GetMembers(tokens, "ghc", "ghc10-attendees");
Assert.IsNotNull(usersInTheList);
@@ -87,7 +87,7 @@ public static void CreateAddAndDelete()
TwitterUser myUser = TwitterAccount.VerifyCredentials(tokens).ResponseObject;
var userIdToAdd = TwitterUser.Show(tokens, userName).ResponseObject.Id;
- var listResponse = TwitterList.GetList(tokens, myUser.ScreenName, listName);
+ var listResponse = TwitterList.Show(tokens, listName);
if (listResponse.Result == RequestResult.FileNotFound)
{
// Create the new list
View
@@ -1,7 +1,9 @@
<NUnitProject>
- <Settings activeconfig="Debug" />
+ <Settings activeconfig="Release" />
<Config name="Debug" binpathtype="Auto">
<assembly path="Twitterizer2.TestCases\bin\Debug\Twitterizer2.TestCases.dll" />
</Config>
- <Config name="Release" binpathtype="Auto" />
+ <Config name="Release" binpathtype="Auto">
+ <assembly path="Twitterizer2.TestCases\bin\Release\Twitterizer2.TestCases.dll" />
+ </Config>
</NUnitProject>
@@ -34,13 +34,7 @@
namespace Twitterizer.Core
{
- /// <summary>
- /// The Command Performer Class
- /// </summary>
- /// <typeparam name="T">The business object the performer should return.</typeparam>
- /// <tocexclude />
- internal static class CommandPerformer<T>
- where T : ITwitterObject
+ internal static class CommandPerformer
{
/// <summary>
/// Performs the action.
@@ -49,7 +43,8 @@ internal static class CommandPerformer<T>
/// <returns>The parsed result of the action.</returns>
/// <seealso cref="Twitterizer.Core.TwitterCommand{T}"/>
/// <seealso cref="Twitterizer.Core.TwitterObject"/>
- public static TwitterResponse<T> PerformAction(ICommand<T> command)
+ public static TwitterResponse<T> PerformAction<T>(ICommand<T> command)
+ where T : ITwitterObject
{
command.Init();
@@ -50,7 +50,7 @@ public static TwitterResponse<TwitterUser> VerifyCredentials(OAuthTokens tokens,
{
Commands.VerifyCredentialsCommand command = new Commands.VerifyCredentialsCommand(tokens, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -75,7 +75,7 @@ public static TwitterResponse<TwitterUser> UpdateProfileColors(OAuthTokens token
{
Commands.UpdateProfileColorsCommand command = new Twitterizer.Commands.UpdateProfileColorsCommand(tokens, options);
- return CommandPerformer<TwitterUser>.PerformAction(command);
+ return CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -91,7 +91,7 @@ public static TwitterResponse<TwitterUser> UpdateProfileImage(OAuthTokens tokens
{
Commands.UpdateProfileImageCommand command = new Twitterizer.Commands.UpdateProfileImageCommand(tokens, image, options);
- return CommandPerformer<TwitterUser>.PerformAction(command);
+ return CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -110,7 +110,7 @@ public static TwitterResponse<TwitterUser> UpdateProfileImage(OAuthTokens tokens
public static TwitterResponse<TwitterUser> UpdateProfile(OAuthTokens tokens, UpdateProfileOptions options)
{
Commands.UpdateProfileCommand command = new Commands.UpdateProfileCommand(tokens, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
}
}
@@ -81,7 +81,7 @@ public class TwitterRateLimitStatus : TwitterObject
public static TwitterResponse<TwitterRateLimitStatus> GetStatus(OAuthTokens tokens, OptionalProperties options)
{
Commands.RateLimitStatusCommand command = new Twitterizer.Commands.RateLimitStatusCommand(tokens, options);
- TwitterResponse<TwitterRateLimitStatus> result = Core.CommandPerformer<TwitterRateLimitStatus>.PerformAction(command);
+ TwitterResponse<TwitterRateLimitStatus> result = Core.CommandPerformer.PerformAction(command);
return result;
}
@@ -51,7 +51,7 @@ public static TwitterResponse<TwitterUser> Create(OAuthTokens tokens, decimal us
{
Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, string.Empty, userId, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -80,7 +80,7 @@ public static TwitterResponse<TwitterUser> Create(OAuthTokens tokens, string scr
{
Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, screenName, -1, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -109,7 +109,7 @@ public static TwitterResponse<TwitterUser> Destroy(OAuthTokens tokens, decimal u
{
Commands.DestroyBlockCommand command = new Commands.DestroyBlockCommand(tokens, string.Empty, userId, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -138,7 +138,7 @@ public static TwitterResponse<TwitterUser> Destroy(OAuthTokens tokens, string sc
{
Commands.DestroyBlockCommand command = new Commands.DestroyBlockCommand(tokens, screenName, -1, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -167,7 +167,7 @@ public static TwitterResponse<TwitterUser> Exists(OAuthTokens tokens, decimal us
{
Commands.ExistsBlockCommand command = new Commands.ExistsBlockCommand(tokens, string.Empty, userId, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -196,7 +196,7 @@ public static TwitterResponse<TwitterUser> Exists(OAuthTokens tokens, string scr
{
Commands.ExistsBlockCommand command = new Commands.ExistsBlockCommand(tokens, screenName, -1, options);
- return Core.CommandPerformer<TwitterUser>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -221,7 +221,7 @@ public static TwitterResponse<TwitterUser> Exists(OAuthTokens tokens, string scr
public static TwitterResponse<TwitterUserCollection> Blocking(OAuthTokens tokens, BlockingOptions options)
{
Commands.BlockingCommand command = new Commands.BlockingCommand(tokens, options);
- return Core.CommandPerformer<TwitterUserCollection>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -245,7 +245,7 @@ public static TwitterResponse<TwitterIdCollection> BlockingIds(OAuthTokens token
{
Commands.BlockingIdsCommand command = new Commands.BlockingIdsCommand(tokens, options);
- return Core.CommandPerformer<TwitterIdCollection>.PerformAction(command);
+ return Core.CommandPerformer.PerformAction(command);
}
/// <summary>
@@ -141,7 +141,7 @@ public static TwitterResponse<TwitterDirectMessageCollection> DirectMessages(OAu
/// </returns>
public static TwitterResponse<TwitterDirectMessageCollection> DirectMessages(OAuthTokens tokens, DirectMessagesOptions options)
{
- return CommandPerformer<TwitterDirectMessageCollection>.PerformAction(new Commands.DirectMessagesCommand(tokens, options));
+ return CommandPerformer.PerformAction(new Commands.DirectMessagesCommand(tokens, options));
}
/// <summary>
@@ -170,7 +170,7 @@ public static TwitterResponse<TwitterDirectMessage> Send(OAuthTokens tokens, dec
{
Commands.SendDirectMessageCommand command = new Commands.SendDirectMessageCommand(tokens, text, userId, options);
- TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
+ TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);
return result;
}
@@ -201,7 +201,7 @@ public static TwitterResponse<TwitterDirectMessage> Send(OAuthTokens tokens, str
{
Commands.SendDirectMessageCommand command = new Commands.SendDirectMessageCommand(tokens, text, screenName, options);
- TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
+ TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);
return result;
}
@@ -228,7 +228,7 @@ public static TwitterResponse<TwitterDirectMessage> Send(OAuthTokens tokens, str
/// </returns>
public static TwitterResponse<TwitterDirectMessageCollection> DirectMessagesSent(OAuthTokens tokens, DirectMessagesSentOptions options)
{
- return CommandPerformer<TwitterDirectMessageCollection>.PerformAction(new Commands.DirectMessagesSentCommand(tokens, options));
+ return CommandPerformer.PerformAction(new Commands.DirectMessagesSentCommand(tokens, options));
}
/// <summary>
@@ -243,7 +243,7 @@ public TwitterResponse<TwitterDirectMessage> Delete(OAuthTokens tokens, Optional
{
Commands.DeleteDirectMessageCommand command = new Commands.DeleteDirectMessageCommand(tokens, this.Id, options);
- TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
+ TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);
return result;
}
@@ -261,7 +261,7 @@ public static TwitterResponse<TwitterDirectMessage> Delete(OAuthTokens tokens, d
{
Commands.DeleteDirectMessageCommand command = new Commands.DeleteDirectMessageCommand(tokens, id, options);
- TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
+ TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);
return result;
}
@@ -61,7 +61,7 @@ private TwitterFavorite()
/// <returns>The favorite status when successful.</returns>
public static TwitterResponse<TwitterStatus> Create(OAuthTokens tokens, decimal statusId, OptionalProperties options)
{
- return CommandPerformer<TwitterStatus>.PerformAction(
+ return CommandPerformer.PerformAction(
new Commands.CreateFavoriteCommand(tokens, statusId, options));
}
@@ -85,7 +85,7 @@ public static TwitterResponse<TwitterStatus> Create(OAuthTokens tokens, decimal
/// <returns>The un-favorited status in the requested format when successful.</returns>
public static TwitterResponse<TwitterStatus> Delete(OAuthTokens tokens, decimal statusId, OptionalProperties options)
{
- return CommandPerformer<TwitterStatus>.PerformAction(
+ return CommandPerformer.PerformAction(
new Commands.DeleteFavoriteCommand(tokens, statusId, options));
}
@@ -110,7 +110,7 @@ public static TwitterResponse<TwitterStatus> Delete(OAuthTokens tokens, decimal
/// <returns>The 20 most recent favorite statuses</returns>
public static TwitterResponse<TwitterStatusCollection> List(OAuthTokens tokens, ListFavoritesOptions options)
{
- return CommandPerformer<TwitterStatusCollection>.PerformAction(
+ return CommandPerformer.PerformAction(
new Commands.ListFavoritesCommand(tokens, options));
}
Oops, something went wrong.

0 comments on commit ec096fd

Please sign in to comment.