Mercurial > silverbladetech
changeset 118:fa4ba8943048
final version
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SilverlightAsyncRestWcf/.nuget/NuGet.Config Sun May 27 19:53:23 2012 +0100 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <solution> + <add key="disableSourceControlIntegration" value="true" /> + </solution> +</configuration> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SilverlightAsyncRestWcf/.nuget/NuGet.targets Sun May 27 19:53:23 2012 +0100 @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> + + <!-- Windows specific commands --> + <NuGetToolsPath Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> + <PackagesConfig Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> + <PackagesDir Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir> + + <!-- We need to launch nuget.exe with the mono command if we're not on windows --> + <NuGetToolsPath Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir).nuget</NuGetToolsPath> + <PackagesConfig Condition=" '$(OS)' != 'Windows_NT' ">packages.config</PackagesConfig> + <PackagesDir Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir)packages</PackagesDir> + + <!-- NuGet command --> + <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath> + <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand> + <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand> + + <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> + + <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> + <PackageSources>""</PackageSources> + + <!-- Enable the restore command to run before builds --> + <RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages> + + <!-- Property that enables building a package from a project --> + <BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage> + + <!-- Commands --> + <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand> + <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand> + + <!-- Make the build depend on restore packages --> + <BuildDependsOn Condition="$(RestorePackages) == 'true'"> + RestorePackages; + $(BuildDependsOn); + </BuildDependsOn> + + <!-- Make the build depend on restore packages --> + <BuildDependsOn Condition="$(BuildPackage) == 'true'"> + $(BuildDependsOn); + BuildPackage; + </BuildDependsOn> + </PropertyGroup> + + <Target Name="CheckPrerequisites"> + <!-- Raise an error if we're unable to locate nuget.exe --> + <Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> + </Target> + + <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> + <Exec Command="$(RestoreCommand)" + Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" /> + + <Exec Command="$(RestoreCommand)" + LogStandardErrorAsError="true" + Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> + </Target> + + <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites"> + <Exec Command="$(BuildCommand)" + Condition=" '$(OS)' != 'Windows_NT' " /> + + <Exec Command="$(BuildCommand)" + LogStandardErrorAsError="true" + Condition=" '$(OS)' == 'Windows_NT' " /> + </Target> +</Project> \ No newline at end of file
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Common/Car.cs Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Common/Car.cs Sun May 27 19:53:23 2012 +0100 @@ -1,10 +1,17 @@ -namespace SilverlightAsyncRestWcf.Common +using System.Runtime.Serialization; + +namespace SilverlightAsyncRestWcf.Common { + [DataContract] public class Car { + [DataMember] public int Id { get; set; } + [DataMember] public string Make { get; set; } + [DataMember] public string Model { get; set; } + [DataMember] public int Year { get; set; } } }
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Common/SilverlightAsyncRestWcf.Common.csproj Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Common/SilverlightAsyncRestWcf.Common.csproj Sun May 27 19:53:23 2012 +0100 @@ -14,6 +14,8 @@ <TargetFrameworkProfile>Profile3</TargetFrameworkProfile> <FileAlignment>512</FileAlignment> <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> + <RestorePackages>true</RestorePackages> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -36,10 +38,8 @@ <Compile Include="Car.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> - <ItemGroup> - <Reference Include="System" /> - </ItemGroup> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.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">
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/CarService.cs Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/CarService.cs Sun May 27 19:53:23 2012 +0100 @@ -1,9 +1,10 @@ using System; +using System.Collections.Generic; using System.Diagnostics.Contracts; using System.IO; -using System.Runtime.Serialization.Json; using System.ServiceModel.Activation; using System.ServiceModel.Web; +using System.Text; using SilverlightAsyncRestWcf.Common; namespace SilverlightAsyncRestWcf.Services @@ -12,12 +13,10 @@ public class CarService : IService<Car> { private readonly IRepository<Car> _repo; - private readonly DataContractJsonSerializer _serializer; public CarService() { _repo = new FakeCarRepository(); - _serializer = new DataContractJsonSerializer(typeof(Car)); } public CarService(IRepository<Car> repo) @@ -25,32 +24,36 @@ _repo = repo; } - [WebGet(UriTemplate = "Car/{id}")] - public string Get(string id) + [WebGet(UriTemplate = "Cars", ResponseFormat = WebMessageFormat.Json)] + public IList<Car> GetAll() { - Contract.Requires((bool)(id != null), "id != null"); - return _repo.GetById(id).ToJSON(); + var cars = _repo.GetAll(); + return cars; + } + + [WebGet(UriTemplate = "Car/{id}", ResponseFormat = WebMessageFormat.Json)] + public Car Get(string id) + { + var car = _repo.GetById(id); + return car; } [WebInvoke(UriTemplate = "Car", Method = "POST")] public void Insert(Car car) { - Contract.Requires((bool)(car != null), "car != null"); _repo.Insert(car); } [WebInvoke(UriTemplate = "Car/{id}", Method = "PUT")] public void Update(string id, Car car) { - Contract.Requires((bool)(car != null), "car != null"); _repo.Update(car); } - [WebInvoke(UriTemplate = "Car({id})", Method = "DELETE")] + [WebInvoke(UriTemplate = "Car/{id}", Method = "DELETE")] public void Delete(string id) { - Contract.Requires((bool)(id != null), "id != null"); _repo.Delete(id); } } -} +} \ No newline at end of file
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/FakeCarRepository.cs Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/FakeCarRepository.cs Sun May 27 19:53:23 2012 +0100 @@ -30,9 +30,9 @@ : null; } - public IQueryable<Car> GetAll() + public IList<Car> GetAll() { - return _data.AsQueryable(); + return _data; } public void Insert(Car entity)
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/IRepository.cs Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/IRepository.cs Sun May 27 19:53:23 2012 +0100 @@ -1,25 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using SilverlightAsyncRestWcf.Common; +using System.Collections.Generic; namespace SilverlightAsyncRestWcf.Services { public interface IRepository<T> where T : class { T GetById(string id); - IQueryable<T> GetAll(); + IList<T> GetAll(); void Insert(T entity); void Update(T entity); void Delete(string id); } - - public interface IRepository - { - object GetById(string id); - IQueryable GetAll(); - void Insert(object entity); - void Update(object entity); - void Delete(string id); - } }
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/IService.cs Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/IService.cs Sun May 27 19:53:23 2012 +0100 @@ -1,4 +1,5 @@ -using System.ServiceModel; +using System.Collections.Generic; +using System.ServiceModel; namespace SilverlightAsyncRestWcf.Services { @@ -6,7 +7,10 @@ interface IService<T> { [OperationContract] - string Get(string id); + IList<T> GetAll(); + + [OperationContract] + T Get(string id); [OperationContract] void Insert(T entity);
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/JSONHelper.cs Sun May 27 15:06:35 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -using System.Web.Script.Serialization; - -namespace SilverlightAsyncRestWcf.Services -{ - public static class JSONHelper - { - public static string ToJSON(this object obj) - { - // DataContractJsonSerializer can be used for tighter WCF integration - // ServiceStack and JSON.NET can be use to provide faster libraries - - var serializer = new JavaScriptSerializer(); - return serializer.Serialize(obj); - } - } -}
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/SilverlightAsyncRestWcf.Services.csproj Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Services/SilverlightAsyncRestWcf.Services.csproj Sun May 27 19:53:23 2012 +0100 @@ -12,6 +12,8 @@ <AssemblyName>SilverlightAsyncRestWcf.Services</AssemblyName> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> + <RestorePackages>true</RestorePackages> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -36,11 +38,10 @@ <Reference Include="System.Runtime.Serialization" /> <Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel.Web" /> - <Reference Include="System.Web.Extensions" /> + <Reference Include="System.XML" /> </ItemGroup> <ItemGroup> <Compile Include="CarService.cs" /> - <Compile Include="JSONHelper.cs" /> <Compile Include="FakeCarRepository.cs" /> <Compile Include="IService.cs" /> <Compile Include="IRepository.cs" /> @@ -53,6 +54,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">
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Web/Global.asax.cs Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Web/Global.asax.cs Sun May 27 19:53:23 2012 +0100 @@ -10,7 +10,7 @@ { protected void Application_Start(object sender, EventArgs e) { - RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(CarService))); + RouteTable.Routes.Add(new ServiceRoute("services", new WebServiceHostFactory(), typeof(CarService))); } } } \ No newline at end of file
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Web/SilverlightAsyncRestWcf.Web.csproj Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.Web/SilverlightAsyncRestWcf.Web.csproj Sun May 27 19:53:23 2012 +0100 @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -15,6 +16,17 @@ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <UseIISExpress>false</UseIISExpress> <SilverlightApplicationList>{1884E77A-06B8-4932-93A7-E49F8AE316FD}|..\SilverlightAsyncRestWcf\SilverlightAsyncRestWcf.csproj|ClientBin|False</SilverlightApplicationList> + <FileUpgradeFlags> + </FileUpgradeFlags> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <OldToolsVersion>4.0</OldToolsVersion> + <IISExpressSSLPort /> + <IISExpressAnonymousAuthentication /> + <IISExpressWindowsAuthentication /> + <IISExpressUseClassicPipelineMode /> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> + <RestorePackages>true</RestorePackages> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -34,25 +46,12 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Microsoft.CSharp" /> <Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel.Activation" /> <Reference Include="System.ServiceModel.Web" /> - <Reference Include="System.Web.DynamicData" /> - <Reference Include="System.Web.Entity" /> - <Reference Include="System.Web.ApplicationServices" /> <Reference Include="System" /> - <Reference Include="System.Data" /> <Reference Include="System.Core" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="System.Web.Extensions" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Drawing" /> <Reference Include="System.Web" /> - <Reference Include="System.Xml" /> - <Reference Include="System.Configuration" /> - <Reference Include="System.Web.Services" /> - <Reference Include="System.EnterpriseServices" /> </ItemGroup> <ItemGroup> <Content Include="ClientBin\SilverlightAsyncRestWcf.xap" /> @@ -80,8 +79,13 @@ <Name>SilverlightAsyncRestWcf.Services</Name> </ProjectReference> </ItemGroup> + <PropertyGroup> + <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> + <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> + </PropertyGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> + <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> + <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" /> <ProjectExtensions> <VisualStudio> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> @@ -101,6 +105,7 @@ </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">
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.sln Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.sln Sun May 27 19:53:23 2012 +0100 @@ -1,6 +1,6 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 11 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightAsyncRestWcf", "SilverlightAsyncRestWcf\SilverlightAsyncRestWcf.csproj", "{1884E77A-06B8-4932-93A7-E49F8AE316FD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightAsyncRestWcf.Web", "SilverlightAsyncRestWcf.Web\SilverlightAsyncRestWcf.Web.csproj", "{17E7255B-8A74-48BC-BC7E-DE137250A312}" @@ -9,28 +9,34 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightAsyncRestWcf.Common", "SilverlightAsyncRestWcf.Common\SilverlightAsyncRestWcf.Common.csproj", "{072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{3FFCBDC7-CFB4-427C-8832-FFC8AED1FC80}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Release|Any CPU.Build.0 = Release|Any CPU + {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Release|Any CPU.Build.0 = Release|Any CPU {17E7255B-8A74-48BC-BC7E-DE137250A312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {17E7255B-8A74-48BC-BC7E-DE137250A312}.Debug|Any CPU.Build.0 = Debug|Any CPU {17E7255B-8A74-48BC-BC7E-DE137250A312}.Release|Any CPU.ActiveCfg = Release|Any CPU {17E7255B-8A74-48BC-BC7E-DE137250A312}.Release|Any CPU.Build.0 = Release|Any CPU + {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1884E77A-06B8-4932-93A7-E49F8AE316FD}.Release|Any CPU.Build.0 = Release|Any CPU {51FDF081-016A-4C35-BE5A-3224E9485749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {51FDF081-016A-4C35-BE5A-3224E9485749}.Debug|Any CPU.Build.0 = Debug|Any CPU {51FDF081-016A-4C35-BE5A-3224E9485749}.Release|Any CPU.ActiveCfg = Release|Any CPU {51FDF081-016A-4C35-BE5A-3224E9485749}.Release|Any CPU.Build.0 = Release|Any CPU - {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {072EF229-0478-4FB2-A4D8-AEB50AC6D6CD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf/MainPage.xaml Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf/MainPage.xaml Sun May 27 19:53:23 2012 +0100 @@ -1,12 +1,29 @@ <UserControl x:Class="SilverlightAsyncRestWcf.MainPage" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="400"> + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="d"> <Grid x:Name="LayoutRoot" Background="White"> - + <StackPanel> + <Button x:Name="LoadDataButton" + Width="100" + Height="40" + Margin="10" + Click="LoadDataButton_Click" + Content="Load Data" /> + <ListBox x:Name="CarsListBox" Height="150" Width="300"> + <ListBox.ItemTemplate> + <DataTemplate> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="{Binding Make}" Width="120" /> + <TextBlock Text="{Binding Model}" Width="120" /> + <TextBlock Text="{Binding Year}" Width="40" /> + </StackPanel> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + </StackPanel> </Grid> </UserControl>
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf/MainPage.xaml.cs Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf/MainPage.xaml.cs Sun May 27 19:53:23 2012 +0100 @@ -1,22 +1,32 @@ using System; -using System.Collections.Generic; -using System.Linq; +using System.IO; using System.Net; +using System.Runtime.Serialization.Json; +using System.Text; using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; +using SilverlightAsyncRestWcf.Common; namespace SilverlightAsyncRestWcf { - public partial class MainPage : UserControl + public partial class MainPage { public MainPage() { InitializeComponent(); } + + private async void LoadDataButton_Click(object sender, RoutedEventArgs e) + { + var request = new WebClient(); + var uri = new Uri("http://localhost:5349/services/cars"); + var jsonString = await request.DownloadStringTaskAsync(uri); + + using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(jsonString.ToCharArray()))) + { + var serializer = new DataContractJsonSerializer(typeof (Car[])); + var cars = (Car[]) serializer.ReadObject(stream); + CarsListBox.ItemsSource = cars; + } + } } -} +} \ No newline at end of file
--- a/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.csproj Sun May 27 15:06:35 2012 +0100 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf.csproj Sun May 27 19:53:23 2012 +0100 @@ -12,7 +12,7 @@ <RootNamespace>SilverlightAsyncRestWcf</RootNamespace> <AssemblyName>SilverlightAsyncRestWcf</AssemblyName> <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkVersion>v5.0</TargetFrameworkVersion> <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion> <SilverlightApplication>true</SilverlightApplication> <SupportedCultures> @@ -31,6 +31,9 @@ <ThrowErrorsInValidation>true</ThrowErrorsInValidation> <LinkedServerProject> </LinkedServerProject> + <TargetFrameworkProfile /> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</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 @@ -60,7 +63,11 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="Microsoft.CompilerServices.AsyncTargetingPack.Silverlight5"> + <HintPath>..\packages\Microsoft.CompilerServices.AsyncTargetingPack.1.0.0\lib\sl50\Microsoft.CompilerServices.AsyncTargetingPack.Silverlight5.dll</HintPath> + </Reference> <Reference Include="mscorlib" /> + <Reference Include="System.ServiceModel.Web" /> <Reference Include="System.Windows" /> <Reference Include="system" /> <Reference Include="System.Core" /> @@ -88,6 +95,7 @@ </Page> </ItemGroup> <ItemGroup> + <None Include="packages.config" /> <None Include="Properties\AppManifest.xml" /> </ItemGroup> <ItemGroup> @@ -111,4 +119,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$(SolutionDir)\.nuget\nuget.targets" /> </Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SilverlightAsyncRestWcf/SilverlightAsyncRestWcf/packages.config Sun May 27 19:53:23 2012 +0100 @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Microsoft.CompilerServices.AsyncTargetingPack" version="1.0.0" /> +</packages> \ No newline at end of file