Permalink
Browse files

Added a project to build the Client for Silverlight 5.

The existing Silverlight Client cannot be used with Silverlight 5 because it uses the System.Threading.Tasks NuGet Package which conflicts with the official implementation of Tasks in Silverlight 5.

The System.Threading.Tasks NuGet package does include a build for Silverlight 5 which uses the official Tasks api, but it also includes a TaskExtensions class containing the Unwrap method, which still conflicts with the official TaskExtensions class. So the System.Threading.Tasks NuGet can't be used with SignalR.Client at present.

Instead, this Check-in includes a stand-in (and very naive) implementation of ConcurrentDictionary which is the only part of the TPL used by SignalR.Client and missing from Silverlight 5.
  • Loading branch information...
1 parent 70da9f0 commit 194c7b49214d53ace0f5e8083f94447eea32a394 @samueldjack samueldjack committed Mar 22, 2012
View
5 Build/Build.proj
@@ -76,6 +76,11 @@
Targets="Build"
Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v4.0')"
Properties="BuildPackage=true;Version=$(Version);PackageOutputDir=$(ArtifactsDir);Configuration=$(Configuration)" />
+
+ <MSBuild Projects="$(ProjectRoot)\SignalR.Client.Silverlight5\SignalR.Client.Silverlight5.csproj"
+ Targets="Build"
+ Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Silverlight\v5.0')"
+ Properties="BuildPackage=true;Version=$(Version);PackageOutputDir=$(ArtifactsDir);Configuration=$(Configuration)" />
<Exec Command="&quot;$(NuGetExePath)&quot; pack &quot;%(JsPackage.Identity)&quot; -o &quot;$(ArtifactsDir)&quot; -p Version=$(Version) -basePath &quot;$(ProjectRoot)\SignalR&quot;"
LogStandardErrorAsError="true" />
View
4 SignalR.Client.Silverlight/SignalR.Client.Silverlight.csproj
@@ -163,7 +163,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="packages.config" />
+ <None Include="packages.config">
+ <SubType>Designer</SubType>
+ </None>
<None Include="Properties\SignalR.Client.Silverlight.nuspec">
<SubType>Designer</SubType>
</None>
View
1 SignalR.Client.Silverlight/packages.config
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="4.0.4" />
<package id="Newtonsoft.Json" version="4.0.7" />
<package id="System.Threading.Tasks" version="2.1.2" />
</packages>
View
166 SignalR.Client.Silverlight5/Impl/ConcurrentDictionary.cs
@@ -0,0 +1,166 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace System.Collections.Concurrent.Standins
+{
+ /// <summary>
+ /// This is a stand-in implementation until Robert McLaws' System.Threading.Tasks package fixes the problem
+ /// with TaskExtensions.Unwrap for Silverlight 5 (the official and unofficial System.Thread.Tasks both include a TaskExtensions class in the same
+ /// namespace).
+ /// </summary>
+ /// <typeparam name="TKey"></typeparam>
+ /// <typeparam name="TValue"></typeparam>
+ public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>
+ {
+ private readonly object _lock = new object();
+ private readonly Dictionary<TKey, TValue> _dictionary ;
+
+ public ConcurrentDictionary(IEqualityComparer<TKey> comparer)
+ {
+ _dictionary = new Dictionary<TKey, TValue>(comparer);
+ }
+
+ public ConcurrentDictionary()
+ {
+ _dictionary = new Dictionary<TKey, TValue>();
+ }
+
+ public void Add(TKey key, TValue value)
+ {
+ lock (_lock)
+ {
+ _dictionary.Add(key, value);
+ }
+ }
+
+ public bool ContainsKey(TKey key)
+ {
+ lock (_lock)
+ {
+ return _dictionary.ContainsKey(key);
+ }
+ }
+
+ public bool Remove(TKey key)
+ {
+ lock (_lock)
+ {
+ return _dictionary.Remove(key);
+ }
+ }
+
+ public bool TryGetValue(TKey key, out TValue value)
+ {
+ lock (_lock)
+ {
+ return _dictionary.TryGetValue(key, out value);
+ }
+ }
+
+ public bool Remove(KeyValuePair<TKey, TValue> item)
+ {
+ lock (_lock)
+ {
+ return ((ICollection<KeyValuePair<TKey, TValue>>) _dictionary).Remove(item);
+ }
+ }
+
+ public int Count
+ {
+ get {
+ lock (_lock)
+ {
+ return _dictionary.Count;
+ }
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public TValue this[TKey key]
+ {
+ get {
+ lock (_lock)
+ {
+ return _dictionary[key];
+ }
+ }
+ set {
+ lock (_lock)
+ {
+ _dictionary[key] = value;
+ }
+ }
+ }
+
+
+ public ICollection<TValue> Values
+ {
+ get {
+ lock (_lock)
+ {
+ return _dictionary.Values.ToList();
+ }
+ }
+ }
+
+ public ICollection<TKey> Keys
+ {
+ get {
+ lock (_lock)
+ {
+ return _dictionary.Keys;
+ }
+ }
+ }
+
+ public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
+ {
+ lock (_lock)
+ {
+ var items = _dictionary.ToList();
+ return items.GetEnumerator();
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ public void Add(KeyValuePair<TKey, TValue> item)
+ {
+ lock (_lock)
+ {
+ _dictionary.Add(item.Key, item.Value);
+ }
+ }
+
+ public void Clear()
+ {
+ lock (_lock)
+ {
+ _dictionary.Clear();
+ }
+ }
+
+ public bool Contains(KeyValuePair<TKey, TValue> item)
+ {
+ lock (_lock)
+ {
+ return ((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).Contains(item);
+ }
+ }
+
+ public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
+ {
+ lock (_lock)
+ {
+ ((ICollection<KeyValuePair<TKey, TValue>>) _dictionary).CopyTo(array, arrayIndex);
+ }
+ }
+ }
+}
View
6 SignalR.Client.Silverlight5/Properties/AssemblyInfo.cs
@@ -0,0 +1,6 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("SignalR.Client.Silverlight5")]
+[assembly: AssemblyDescription("Silverlight 5 client for SignalR")]
View
16 SignalR.Client.Silverlight5/Properties/SignalR.Client.Silverlight5.nuspec
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<package >
+ <metadata>
+ <id>$id$</id>
+ <version>$version$</version>
+ <title>$title$</title>
+ <authors>$author$</authors>
+ <licenseUrl>https://github.com/SignalR/SignalR/blob/master/LICENSE.md</licenseUrl>
+ <projectUrl>https://github.com/SignalR/SignalR</projectUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>$description$</description>
+ <dependencies>
+ <dependency id="Newtonsoft.Json" version="[4.0.7]" />
+ </dependencies>
+ </metadata>
+</package>
View
187 SignalR.Client.Silverlight5/SignalR.Client.Silverlight5.csproj
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{0220B607-1686-4D4A-AEF0-292EA9827531}</ProjectGuid>
+ <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SignalR.Client.Silverlight5</RootNamespace>
+ <AssemblyName>SignalR.Client.Silverlight5</AssemblyName>
+ <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
+ <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
+ <SilverlightApplication>false</SilverlightApplication>
+ <ValidateXaml>true</ValidateXaml>
+ <ThrowErrorsInValidation>true</ThrowErrorsInValidation>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\SignalR\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <!-- This property group is only here to support building this project using the
+ MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
+ to set the TargetFrameworkVersion to v3.5 -->
+ <PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>Bin\Debug</OutputPath>
+ <DefineConstants>TRACE;DEBUG;SILVERLIGHT SILVERLIGHT5</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>Bin\Release</OutputPath>
+ <DefineConstants>TRACE;SILVERLIGHT SILVERLIGHT5</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="mscorlib" />
+ <Reference Include="Newtonsoft.Json, Version=4.0.7.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Newtonsoft.Json.4.0.7\lib\sl4\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <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="Impl\ConcurrentDictionary.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\Common\CommonAssemblyInfo.cs">
+ <Link>Properties\CommonAssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Connection.cs">
+ <Link>Connection.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\ConnectionExtensions.cs">
+ <Link>ConnectionExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\HubClientInvocation.cs">
+ <Link>Hubs\HubClientInvocation.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\HubConnection.cs">
+ <Link>Hubs\HubConnection.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\HubProxy.cs">
+ <Link>Hubs\HubProxy.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\HubProxyExtensions.cs">
+ <Link>Hubs\HubProxyExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\HubRegistrationData.cs">
+ <Link>Hubs\HubRegistrationData.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\HubResult.cs">
+ <Link>Hubs\HubResult.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\HubServerInvocation.cs">
+ <Link>Hubs\HubServerInvocation.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\IHubProxy.cs">
+ <Link>Hubs\IHubProxy.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Hubs\Subscription.cs">
+ <Link>Hubs\Subscription.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\IConnection.cs">
+ <Link>IConnection.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\ChunkBuffer.cs">
+ <Link>Infrastructure\ChunkBuffer.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\DefaultHttpClient.cs">
+ <Link>Infrastructure\DefaultHttpClient.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\DisposableAction.cs">
+ <Link>Infrastructure\DisposableAction.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\HttpHelper.cs">
+ <Link>Infrastructure\HttpHelper.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\HttpWebRequestWrapper.cs">
+ <Link>Infrastructure\HttpWebRequestWrapper.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\HttpWebResponseWrapper.cs">
+ <Link>Infrastructure\HttpWebResponseWrapper.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\IHttpClient.cs">
+ <Link>Infrastructure\IHttpClient.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\IHttpClientExtensions.cs">
+ <Link>Infrastructure\IHttpClientExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\IRequest.cs">
+ <Link>Infrastructure\IHttpRequest.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\IResponse.cs">
+ <Link>Infrastructure\IHttpResponse.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Infrastructure\StreamExtensions.cs">
+ <Link>Infrastructure\StreamExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\NegotiationResponse.cs">
+ <Link>NegotiationResponse.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Properties\VersionInfo.cs">
+ <Link>Properties\VersionInfo.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Transports\AutoTransport.cs">
+ <Link>Transports\AutoTransport.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Transports\HttpBasedTransport.cs">
+ <Link>Transports\HttpBasedTransport.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Transports\IClientTransport.cs">
+ <Link>Transports\IClientTransport.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Transports\LongPollingTransport.cs">
+ <Link>Transports\LongPollingTransport.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR.Client\Transports\ServerSentEventsTransport.cs">
+ <Link>Transports\ServerSentEventsTransport.cs</Link>
+ </Compile>
+ <Compile Include="..\SignalR\TaskAsyncHelper.cs">
+ <Link>Infrastructure\TaskAsyncHelper.cs</Link>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ <None Include="Properties\SignalR.Client.Silverlight5.nuspec">
+ <SubType>Designer</SubType>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
+ <SilverlightProjectProperties />
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
4 SignalR.Client.Silverlight5/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Newtonsoft.Json" version="4.0.7" />
+</packages>
View
4 SignalR.Client/Connection.cs
@@ -9,6 +9,10 @@
using SignalR.Client.Infrastructure;
using SignalR.Client.Transports;
+#if SILVERLIGHT5
+using System.Collections.Concurrent.Standins;
+#endif
+
namespace SignalR.Client
{
public class Connection : IConnection
View
3 SignalR.Hosting.Memory/SignalR.Hosting.Memory.csproj
@@ -12,6 +12,8 @@
<AssemblyName>SignalR.Hosting.Memory</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\SignalR\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -60,6 +62,7 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
View
6 SignalR.Silverlight.sln
@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{1E4BA77C
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignalR.Client.Silverlight", "SignalR.Client.Silverlight\SignalR.Client.Silverlight.csproj", "{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignalR.Client.Silverlight5", "SignalR.Client.Silverlight5\SignalR.Client.Silverlight5.csproj", "{0220B607-1686-4D4A-AEF0-292EA9827531}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -31,6 +33,10 @@ Global
{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0220B607-1686-4D4A-AEF0-292EA9827531}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0220B607-1686-4D4A-AEF0-292EA9827531}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0220B607-1686-4D4A-AEF0-292EA9827531}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0220B607-1686-4D4A-AEF0-292EA9827531}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

0 comments on commit 194c7b4

Please sign in to comment.