Skip to content

Commit

Permalink
Merge pull request #42 from blooksa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
DigitallyBorn committed Jan 24, 2013
2 parents a543d7a + eab7504 commit c8337fb
Show file tree
Hide file tree
Showing 42 changed files with 51,025 additions and 98 deletions.
6 changes: 0 additions & 6 deletions Twitterizer.OAuth/Twitterizer.OAuth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json, Version=4.0.5.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.0.5\lib\sl4\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Net" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Twitterizer2.Async\AsyncUtility.cs">
Expand Down
10 changes: 2 additions & 8 deletions Twitterizer2.Async/Twitterizer2.Async.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,11 @@
<AssemblyOriginatorKeyFile>..\Twitterizer2\Twitterizer2.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.0.5.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
Expand Down
2 changes: 1 addition & 1 deletion Twitterizer2.Async/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.0.5" />
<package id="Newtonsoft.Json" version="4.5.7" />
</packages>
3 changes: 0 additions & 3 deletions Twitterizer2.Silverlight/Twitterizer2.Silverlight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,11 @@
<HintPath>..\packages\Newtonsoft.Json.4.0.5\lib\sl4\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Net" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Net" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Twitterizer2.Streaming\FilterStreamOptions.cs">
Expand Down
10 changes: 10 additions & 0 deletions Twitterizer2.Streaming/StreamOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,15 @@ public StreamOptions()
/// <value>Boolean.</value>
/// <remarks>Will use the recently introduced GZip compression to decrease bandwitdth.</remarks>
public bool UseCompression { get; set; }

#if !SILVERLIGHT
/// <summary>
/// Gets or sets the proxy.
/// </summary>
/// <value>
/// The proxy.
/// </value>
public System.Net.WebProxy Proxy { get; set; }
#endif
}
}
45 changes: 45 additions & 0 deletions Twitterizer2.Streaming/TwitterStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,45 @@ public IAsyncResult StartPublicStream(
return request.BeginGetResponse(StreamCallback, request);
}

/// <summary>
/// Starts the sample stream.
/// </summary>
public IAsyncResult StartSampleStream(
StreamStoppedCallback streamStoppedCallback,
StatusCreatedCallback statusCreatedCallback,
StatusDeletedCallback statusDeletedCallback,
EventCallback eventCallback,
RawJsonCallback rawJsonCallback = null
)
{
if (request != null)
{
throw new InvalidOperationException("Stream is already open");
}

WebRequestBuilder builder;
if (Tokens == null)
builder = new WebRequestBuilder(new Uri("https://stream.twitter.com/1/statuses/sample.json"),
HTTPVerb.POST, userAgent, NetworkCredentials);
else
builder = new WebRequestBuilder(new Uri("https://stream.twitter.com/1/statuses/sample.json"),
HTTPVerb.POST, Tokens, userAgent);
PrepareStreamOptions(builder);

request = builder.PrepareRequest();

this.streamStoppedCallback = streamStoppedCallback;
this.statusCreatedCallback = statusCreatedCallback;
this.statusDeletedCallback = statusDeletedCallback;
this.eventCallback = eventCallback;
this.rawJsonCallback = rawJsonCallback;
stopReceived = false;
#if SILVERLIGHT
request.AllowReadStreamBuffering = false;
#endif
return request.BeginGetResponse(StreamCallback, request);
}

/// <summary>
/// Prepares the stream options.
/// </summary>
Expand All @@ -283,6 +322,12 @@ private void PrepareStreamOptions(WebRequestBuilder builder)
builder.Parameters.Add("track", string.Join(",", StreamOptions.Track.ToArray()));

builder.UseCompression = StreamOptions.UseCompression;

#if !SILVERLIGHT

if (this.StreamOptions != null)
builder.Proxy = this.StreamOptions.Proxy;
#endif
}
}

Expand Down
14 changes: 2 additions & 12 deletions Twitterizer2.Streaming/Twitterizer2.Streaming.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,14 @@
<AssemblyOriginatorKeyFile>..\Twitterizer2\Twitterizer2.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.0.5.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
Expand Down
2 changes: 1 addition & 1 deletion Twitterizer2.Streaming/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.0.5" />
<package id="Newtonsoft.Json" version="4.5.7" />
</packages>
1 change: 0 additions & 1 deletion Twitterizer2.TestCases/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
10 changes: 5 additions & 5 deletions Twitterizer2.TestCases/TwitterStatusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public static void UpdateAndDelete()
TwitterStatus deletedStatus = newStatus.Delete(tokens).ResponseObject;
Assert.That(newStatus.Id == deletedStatus.Id);
}

[Category("Core")]
[Test]
[ExpectedException(ExpectedException=typeof(ArgumentException))]
[ExpectedException(ExpectedException = typeof(ArgumentException))]
public static void TestTokenValidation()
{
OAuthTokens fakeTokens = new OAuthTokens();
Expand Down Expand Up @@ -112,8 +112,8 @@ public static void DetectEntities()
TwitterResponse<TwitterStatusCollection> timelineResult = TwitterTimeline.PublicTimeline();

// Get the first tweet with entities
TwitterStatus tweet = timelineResult.ResponseObject.Where(x => x.Entities != null && x.Entities.OfType<TwitterMentionEntity>().Count() > 0).First();
TwitterStatus tweet = timelineResult.ResponseObject.First(x => x.Entities != null && x.Entities.OfType<TwitterMentionEntity>().Any());

// Make sure that we got the tweet successfully
Assert.IsNotNull(tweet);

Expand All @@ -123,7 +123,7 @@ public static void DetectEntities()

// Get the mentions (@screenname within the text)
var mentions = from entities in tweet.Entities.OfType<TwitterMentionEntity>()
select entities;
select entities;

// Get urls
//var urls = from entities in tweet.Entities.OfType<TwitterUrlEntity>()
Expand Down
12 changes: 2 additions & 10 deletions Twitterizer2.TestCases/Twitterizer2.TestCases.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.0.5.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -77,14 +77,6 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Twitterizer2\Core\SerializationHelper.cs">
Expand Down
2 changes: 1 addition & 1 deletion Twitterizer2.TestCases/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.0.5" />
<package id="Newtonsoft.Json" version="4.5.7" />
<package id="NUnit" version="2.6.0.12054" />
</packages>
33 changes: 29 additions & 4 deletions Twitterizer2/Core/SerializationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Twitterizer.Core
/// The Serialization Helper class. Provides a simple interface for common serialization tasks.
/// </summary>
/// <typeparam name="T">The type of object to be deserialized</typeparam>
internal static class SerializationHelper<T>
public static class SerializationHelper<T>
where T : ITwitterObject
{
/// <summary>
Expand All @@ -62,17 +62,42 @@ internal static class SerializationHelper<T>
/// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
/// </returns>
public static T Deserialize(byte[] webResponseData, DeserializationHandler deserializationHandler)
{
return Deserialize(Encoding.UTF8.GetString(webResponseData, 0, webResponseData.Length), deserializationHandler);
}

/// <summary>
/// Deserializes the specified web response.
/// </summary>
/// <param name="webResponseData">The web response data.</param>
/// <returns>
/// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
/// </returns>
public static T Deserialize(byte[] webResponseData)
{
return Deserialize(Encoding.UTF8.GetString(webResponseData, 0, webResponseData.Length), null);
}

/// <summary>
/// Deserializes the specified web response.
/// </summary>
/// <param name="webResponseData">The web response data.</param>
/// <param name="deserializationHandler">The deserialization handler.</param>
/// <returns>
/// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
/// </returns>
public static T Deserialize(string webResponseData, DeserializationHandler deserializationHandler)
{
T resultObject;

// Deserialize the results.
if (deserializationHandler == null)
{
resultObject = JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(webResponseData, 0, webResponseData.Length));
resultObject = JsonConvert.DeserializeObject<T>(webResponseData);
}
else
{
resultObject = deserializationHandler((JObject)JsonConvert.DeserializeObject(Encoding.UTF8.GetString(webResponseData, 0, webResponseData.Length)));
resultObject = deserializationHandler((JObject)JsonConvert.DeserializeObject(webResponseData));
}

return resultObject;
Expand All @@ -85,7 +110,7 @@ public static T Deserialize(byte[] webResponseData, DeserializationHandler deser
/// <returns>
/// A strongly typed object representing the deserialized data of type <typeparamref name="T"/>
/// </returns>
public static T Deserialize(byte[] webResponseData)
public static T Deserialize(string webResponseData)
{
return Deserialize(webResponseData, null);
}
Expand Down
5 changes: 4 additions & 1 deletion Twitterizer2/Methods/Geo/Coordinate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
return null;
}

if (reader.TokenType == JsonToken.StartArray)
reader.Read();

//int depth = reader.Depth + 1;
double count = 1;

while (reader.Read() && reader.Depth >= startDepth)
while (reader.Read() && reader.Depth > startDepth)
{
if (new[] { JsonToken.StartArray, JsonToken.EndArray }.Contains(reader.TokenType))
continue;
Expand Down
7 changes: 1 addition & 6 deletions Twitterizer2/Methods/List/DestroyListSubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Twitterizer.Commands
namespace Twitterizer.Commands
{
[Core.AuthorizedCommand]
internal class DestroyListSubscriber : Core.TwitterCommand<TwitterList>
Expand Down
10 changes: 5 additions & 5 deletions Twitterizer2/Methods/List/ListMembershipsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ internal sealed class ListMembershipsCommand : TwitterCommand<TwitterListCollect
/// Initializes a new instance of the <see cref="ListMembershipsCommand"/> class.
/// </summary>
/// <param name="requestTokens">The request tokens.</param>
/// <param name="username">The screenname.</param>
/// <param name="screenname">The screenname.</param>
/// <param name="options">The options.</param>
public ListMembershipsCommand(OAuthTokens requestTokens, string screenname, ListMembershipsOptions options)
: base(
HTTPVerb.GET,
"lists/memberships.json",
requestTokens,
HTTPVerb.GET,
"lists/memberships.json",
requestTokens,
options)
{
if (string.IsNullOrEmpty(screenname))
Expand All @@ -79,7 +79,7 @@ public ListMembershipsCommand(OAuthTokens requestTokens, string screenname, List
/// Initializes a new instance of the <see cref="ListMembershipsCommand"/> class.
/// </summary>
/// <param name="requestTokens">The request tokens.</param>
/// <param name="username">The screenname.</param>
/// <param name="userid">The screenname.</param>
/// <param name="options">The options.</param>
public ListMembershipsCommand(OAuthTokens requestTokens, decimal userid, ListMembershipsOptions options)
: base(
Expand Down
Loading

0 comments on commit c8337fb

Please sign in to comment.