Permalink
Browse files

No commit message

  • Loading branch information...
digitallyborn
digitallyborn committed May 11, 2010
1 parent f54c4bd commit e7135a633e5e03fd5f8e932ffa21e3acf544ed7c
Showing with 714 additions and 524 deletions.
  1. +7 −0 Json.NET.license.txt
  2. +1 −1 Twitterizer-Desktop/MainForm.cs
  3. +2 −2 Twitterizer-Web/followers.aspx.cs
  4. +2 −2 Twitterizer-Web/friends.aspx.cs
  5. +2 −2 Twitterizer-Web/user.aspx.cs
  6. +13 −0 Twitterizer2/Core/CursorPagedCommand.cs
  7. +1 −1 Twitterizer2/Core/RequestStatus.cs
  8. +42 −35 Twitterizer2/Core/SerializationHelper.cs
  9. +7 −18 Twitterizer2/Core/TwitterCommand.cs
  10. +99 −0 Twitterizer2/Core/TwitterizerDateConverter.cs
  11. +10 −0 Twitterizer2/Exceptions/TwitterErrorDetails.cs
  12. +2 −2 Twitterizer2/Exceptions/TwitterizerException.cs
  13. +2 −2 Twitterizer2/Methods/Account/TwitterRateLimitStatus.cs
  14. +2 −2 Twitterizer2/Methods/Direct Message/DeleteDirectMessageCommand.cs
  15. +2 −4 Twitterizer2/Methods/Direct Message/DirectMessagesOptions.cs
  16. +2 −4 Twitterizer2/Methods/Direct Message/DirectMessagesSentOptions.cs
  17. +1 −1 Twitterizer2/Methods/Direct Message/SendDirectMessageCommand.cs
  18. +6 −10 Twitterizer2/Methods/Direct Message/TwitterDirectMessage.cs
  19. +1 −1 Twitterizer2/Methods/Friendship/CreateFriendshipCommand.cs
  20. +1 −1 Twitterizer2/Methods/Friendship/DeleteFriendshipCommand.cs
  21. +2 −2 Twitterizer2/Methods/Friendship/ShowFriendshipCommand.cs
  22. +6 −22 Twitterizer2/Methods/Friendship/TwitterFriendship.cs
  23. +126 −0 Twitterizer2/Methods/Geo/ReverseGeocodeCommand.cs
  24. +14 −44 Twitterizer2/Methods/{Timeline/HomeTimelineOptions.cs → Geo/TwitterBoundingBox.cs}
  25. +124 −0 Twitterizer2/Methods/Geo/TwitterPlace.cs
  26. +8 −0 Twitterizer2/Methods/Geo/TwitterPlaceCollection.cs
  27. +1 −12 Twitterizer2/Methods/Search/CurrentTrendsCommand.cs
  28. +0 −2 Twitterizer2/Methods/Streaming/TwitterStream.cs
  29. +3 −3 Twitterizer2/Methods/Timeline/FriendsTimelineCommand.cs
  30. +0 −85 Twitterizer2/Methods/Timeline/FriendsTimelineOptions.cs
  31. +6 −6 Twitterizer2/Methods/Timeline/HomeTimelineCommand.cs
  32. +2 −2 Twitterizer2/Methods/Timeline/MentionsCommand.cs
  33. +2 −2 Twitterizer2/Methods/Timeline/RetweetedByMeCommand.cs
  34. +2 −2 Twitterizer2/Methods/Timeline/RetweetedToMeCommand.cs
  35. +49 −0 Twitterizer2/Methods/Timeline/TimelineOptions.cs
  36. +46 −35 Twitterizer2/Methods/Timeline/TwitterTimeline.cs
  37. +31 −41 Twitterizer2/Methods/Timeline/UserTimelineCommand.cs
  38. +22 −22 Twitterizer2/Methods/Trends/TwitterTrendTimeframe.cs
  39. +2 −2 Twitterizer2/Methods/Tweets/DeleteStatusCommand.cs
  40. +1 −1 Twitterizer2/Methods/Tweets/RetweetCommand.cs
  41. +2 −2 Twitterizer2/Methods/Tweets/RetweetsCommand.cs
  42. +2 −2 Twitterizer2/Methods/Tweets/RetweetsOfMeCommand.cs
  43. +2 −2 Twitterizer2/Methods/Tweets/ShowStatusCommand.cs
  44. +1 −2 Twitterizer2/Methods/Tweets/StatusUpdateOptions.cs
  45. +21 −23 Twitterizer2/Methods/Tweets/TwitterStatus.cs
  46. +1 −1 Twitterizer2/Methods/User/FollowersCommand.cs
  47. +2 −2 Twitterizer2/Methods/User/FriendsCommand.cs
  48. +1 −1 Twitterizer2/Methods/User/ShowUserCommand.cs
  49. +11 −18 Twitterizer2/Methods/User/TwitterUser.cs
  50. +7 −4 Twitterizer2/Methods/User/TwitterUserWrapper.cs
  51. +3 −3 Twitterizer2/Properties/AssemblyInfo.cs
  52. +0 −69 Twitterizer2/Properties/AssemblyInfo.cs.template
  53. +9 −6 Twitterizer2/Twitterizer2.csproj
  54. +0 −18 lib/SubWCRev.bat
  55. BIN lib/SubWCRev_x32.exe
  56. BIN lib/SubWCRev_x64.exe
  57. BIN lib/Twitterizer2 Command Class.zip
View
@@ -0,0 +1,7 @@
+Copyright (c) 2007 James Newton-King
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -122,7 +122,7 @@ private void AuthorizeAndGetUser()
ConsumerSecret = ConfigurationManager.AppSettings["Twitterizer.Desktop.ConsumerSecret"]
};
- ulong userId = ulong.Parse(ConfigurationManager.AppSettings["Twitterizer.Desktop.UserId"]);
+ decimal userId = decimal.Parse(ConfigurationManager.AppSettings["Twitterizer.Desktop.UserId"]);
try
{
@@ -44,8 +44,8 @@ protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
- ulong userId = 0;
- if (!string.IsNullOrEmpty(Request.QueryString["userid"]) && ulong.TryParse(Request.QueryString["userid"], out userId))
+ decimal userId = 0;
+ if (!string.IsNullOrEmpty(Request.QueryString["userid"]) && decimal.TryParse(Request.QueryString["userid"], out userId))
{
this.FollowersCollection = TwitterFriendship.Followers(Master.Tokens, userId);
}
@@ -43,9 +43,9 @@ protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
- ulong userId = 0;
+ decimal userId = 0;
- if (!string.IsNullOrEmpty(Request.QueryString["userid"]) && ulong.TryParse(Request.QueryString["userid"], out userId))
+ if (!string.IsNullOrEmpty(Request.QueryString["userid"]) && decimal.TryParse(Request.QueryString["userid"], out userId))
{
this.FriendsCollection = TwitterFriendship.Friends(Master.Tokens, userId);
}
@@ -40,9 +40,9 @@ public partial class user : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
- ulong userId = 0;
+ decimal userId = 0;
- if (string.IsNullOrEmpty(Request.QueryString["id"]) || !ulong.TryParse(Request.QueryString["id"], out userId))
+ if (string.IsNullOrEmpty(Request.QueryString["id"]) || !decimal.TryParse(Request.QueryString["id"], out userId))
{
Response.Redirect("~/", true);
}
@@ -50,11 +50,24 @@ internal abstract class CursorPagedCommand<T> : TwitterCommand<T>
/// <param name="method">The method.</param>
/// <param name="uri">The URI for the API method.</param>
/// <param name="tokens">The request tokens.</param>
+ [Obsolete]
protected CursorPagedCommand(string method, Uri uri, OAuthTokens tokens)
: base(method, uri, tokens)
{
}
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CursorPagedCommand&lt;T&gt;"/> class.
+ /// </summary>
+ /// <param name="method">The method.</param>
+ /// <param name="endPoint">The end point.</param>
+ /// <param name="tokens">The tokens.</param>
+ /// <param name="options">The options.</param>
+ protected CursorPagedCommand(string method, string endPoint, OAuthTokens tokens, OptionalProperties options)
+ : base(method, endPoint, tokens, options)
+ {
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="CursorPagedCommand&lt;T&gt;"/> class.
/// </summary>
@@ -217,7 +217,7 @@ public static bool UpdateRequestStatus(HttpWebResponse webResponse)
if (webResponse.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
{
- LastRequestStatus.ErrorDetails = SerializationHelper<TwitterErrorDetails>.Deserialize(webResponse, Serializer.JSONdotNet, null);
+ LastRequestStatus.ErrorDetails = SerializationHelper<TwitterErrorDetails>.Deserialize(webResponse);
}
}
catch (System.Runtime.Serialization.SerializationException)
@@ -38,24 +38,8 @@ namespace Twitterizer.Core
using System.IO;
using System.Net;
using System.Text;
- using System.Web.Script.Serialization;
using Newtonsoft.Json;
-
- /// <summary>
- /// Supported serialization schemes
- /// </summary>
- internal enum Serializer
- {
- /// <summary>
- /// Utilizes the Newtonsoft.Json library for serialization
- /// </summary>
- JSONdotNet,
-
- /// <summary>
- /// Utilizes the AJAX JavaScript serialization classes for semi-manual JSON parsing.
- /// </summary>
- JavaScriptSerializer
- }
+ using Newtonsoft.Json.Linq;
/// <summary>
/// The Serialization Helper class. Provides a simple interface for common serialization tasks.
@@ -69,16 +53,17 @@ internal static class SerializationHelper<T>
/// </summary>
/// <param name="value">Contains nested dictionary objects containing deserialized values for manual parsing.</param>
/// <returns>A strongly typed object representing the deserialized data of type <typeparamref name="T"/></returns>
- public delegate T JavascriptConversionDelegate(object value);
+ public delegate T DeserializationHandler(JObject value);
/// <summary>
/// Deserializes the specified web response.
/// </summary>
/// <param name="webResponse">The web response.</param>
- /// <param name="serializer">The serializer.</param>
/// <param name="javascriptConversionDeligate">The javascript conversion deligate.</param>
- /// <returns>A strongly typed object representing the deserialized data of type <typeparamref name="T"/></returns>
- public static T Deserialize(WebResponse webResponse, Serializer serializer, JavascriptConversionDelegate javascriptConversionDeligate)
+ /// <returns>
+ /// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
+ /// </returns>
+ public static T Deserialize(WebResponse webResponse, DeserializationHandler deserializationHandler)
{
try
{
@@ -95,7 +80,7 @@ public static T Deserialize(WebResponse webResponse, Serializer serializer, Java
#endif
// Deserialize the results.
- resultObject = Deserialize(serializer, javascriptConversionDeligate, data);
+ resultObject = Deserialize(data, deserializationHandler);
responseStream.Close();
@@ -110,30 +95,52 @@ public static T Deserialize(WebResponse webResponse, Serializer serializer, Java
}
}
+ /// <summary>
+ /// Deserializes the specified web response.
+ /// </summary>
+ /// <param name="webResponse">The web response.</param>
+ /// <returns>
+ /// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
+ /// </returns>
+ public static T Deserialize(WebResponse webResponse)
+ {
+ return Deserialize(webResponse, null);
+ }
+
/// <summary>
/// Deserializes the specified serializer.
/// </summary>
- /// <param name="serializer">The serializer.</param>
- /// <param name="javascriptConversionDeligate">The javascript conversion deligate.</param>
/// <param name="data">The data to be deserialized.</param>
- /// <returns>A strongly typed object representing the deserialized data of type <typeparamref name="T"/></returns>
- public static T Deserialize(Serializer serializer, JavascriptConversionDelegate javascriptConversionDeligate, byte[] data)
+ /// <param name="javascriptConversionDeligate">The javascript conversion deligate.</param>
+ /// <returns>
+ /// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
+ /// </returns>
+ public static T Deserialize(byte[] data, DeserializationHandler javascriptConversionDeligate)
{
T resultObject = default(T);
- switch (serializer)
+ if (javascriptConversionDeligate == null)
+ {
+ resultObject = JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(data));
+ }
+ else
{
- case Serializer.JavaScriptSerializer:
- JavaScriptSerializer jss = new JavaScriptSerializer();
- object result = jss.DeserializeObject(Encoding.UTF8.GetString(data));
- resultObject = javascriptConversionDeligate(result);
- break;
- case Serializer.JSONdotNet:
- resultObject = JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(data));
- break;
+ resultObject = javascriptConversionDeligate((JObject)JsonConvert.DeserializeObject(Encoding.UTF8.GetString(data)));
}
return resultObject;
}
+
+ /// <summary>
+ /// Deserializes the specified serializer.
+ /// </summary>
+ /// <param name="data">The data to be deserialized.</param>
+ /// <returns>
+ /// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
+ /// </returns>
+ public static T Deserialize(byte[] data)
+ {
+ return Deserialize(data, null);
+ }
}
}
@@ -104,12 +104,6 @@ protected TwitterCommand(string httpMethod, OAuthTokens tokens)
this.OptionalProperties = new OptionalProperties();
}
- /// <summary>
- /// Gets or sets the selected serializer.
- /// </summary>
- /// <value>The selected serializer.</value>
- public Serializer SelectedSerializer { get; set; }
-
/// <summary>
/// Gets or sets the optional properties.
/// </summary>
@@ -140,6 +134,12 @@ protected TwitterCommand(string httpMethod, OAuthTokens tokens)
/// <value>The request parameters.</value>
public Dictionary<string, string> RequestParameters { get; set; }
+ /// <summary>
+ /// Gets or sets the serialization delegate.
+ /// </summary>
+ /// <value>The serialization delegate.</value>
+ public SerializationHelper<T>.DeserializationHandler DeserializationHandler { get; set; }
+
/// <summary>
/// Gets the request tokens.
/// </summary>
@@ -248,8 +248,7 @@ public T ExecuteCommand()
resultObject = SerializationHelper<T>.Deserialize(
webResponse,
- this.SelectedSerializer,
- this.ConvertJavaScriptSerializedObject);
+ this.DeserializationHandler);
this.AddResultToCache(cacheKeyBuilder, cache, resultObject);
@@ -285,16 +284,6 @@ public T ExecuteCommand()
return resultObject;
}
- /// <summary>
- /// Converts a weakly typed deserialized javascript object to a strongly typed object.
- /// </summary>
- /// <param name="value">The value.</param>
- /// <returns>A strongly typed representation of the JSON data of type <typeparamref name="T"/></returns>
- public virtual T ConvertJavaScriptSerializedObject(object value)
- {
- throw new NotImplementedException();
- }
-
/// <summary>
/// Clones this instance.
/// </summary>
@@ -0,0 +1,99 @@
+//-----------------------------------------------------------------------
+// <copyright file="TwitterizerDateConverter.cs" company="Patrick 'Ricky' Smith">
+// This file is part of the Twitterizer library (http://code.google.com/p/twitterizer/)
+//
+// Copyright (c) 2010, Patrick "Ricky" Smith (ricky@digitally-born.com)
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this list
+// of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+// - Neither the name of the Twitterizer nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+// </copyright>
+// <author>Ricky Smith</author>
+// <summary>The date converter for Twitter API dates</summary>
+//-----------------------------------------------------------------------
+
+namespace Twitterizer
+{
+ using System;
+ using System.Globalization;
+
+ /// <summary>
+ /// Converts date strings returned by the Twitter API into <see cref="System.DateTime"/>
+ /// </summary>
+ internal class TwitterizerDateConverter : Newtonsoft.Json.Converters.DateTimeConverterBase
+ {
+ /// <summary>
+ /// The date pattern for most dates returned by the API
+ /// </summary>
+ protected const string DateFormat = "ddd MMM dd HH:mm:ss zz00 yyyy";
+
+ /// <summary>
+ /// Reads the json.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ /// <param name="objectType">Type of the object.</param>
+ /// <param name="existingValue">The existing value.</param>
+ /// <param name="serializer">The serializer.</param>
+ /// <returns></returns>
+ public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
+ {
+ try
+ {
+ if (reader.Value == null || reader.Value.GetType() != typeof(string))
+ return new DateTime();
+
+ DateTime parsedDate;
+
+ if (DateTime.TryParseExact(
+ (string)reader.Value,
+ DateFormat,
+ CultureInfo.InvariantCulture,
+ DateTimeStyles.None,
+ out parsedDate))
+ {
+ return parsedDate;
+ }
+ else
+ {
+ return new DateTime();
+ }
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+ }
+
+ /// <summary>
+ /// Writes the json.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ /// <param name="value">The value.</param>
+ /// <param name="serializer">The serializer.</param>
+ public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
@@ -64,24 +64,34 @@ public class TwitterErrorDetails : ITwitterObject
#region ITwitterObject Members
+ /// <summary>
+ /// Gets or sets information about the user's rate usage.
+ /// </summary>
+ /// <value>The rate limiting object.</value>
public RateLimiting RateLimiting
{
get
{
throw new System.NotImplementedException();
}
+
set
{
throw new System.NotImplementedException();
}
}
+ /// <summary>
+ /// Gets or sets the oauth tokens.
+ /// </summary>
+ /// <value>The oauth tokens.</value>
public OAuthTokens Tokens
{
get
{
throw new System.NotImplementedException();
}
+
set
{
throw new System.NotImplementedException();
Oops, something went wrong.

0 comments on commit e7135a6

Please sign in to comment.