Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Updated to the latest asp.net web api release #5

Merged
merged 2 commits into from

2 participants

@pcibraro

The code did not compile with the latest asp.net web api release in nuget. I made a few changes to make it compile.

@JakeGinnivan

Could you also checkin the changes to the packages.config and the .csproj file to include the update?

@pcibraro

The WebApi.Hal project was referencing the System.Net.Http.Formatting assembly from the MVC installation folder, and not Nuget. I made a few changes to the project to change that.

@JakeGinnivan JakeGinnivan merged commit 295e042 into JakeGinnivan:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
8 WebApi.Hal.Tests/HalResourceListTests.cs
@@ -28,13 +28,13 @@ public void organisation_list_get_xml_test()
{
// arrange
var mediaFormatter = new XmlHalMediaTypeFormatter();
- var contentHeaders = new StringContent(string.Empty).Headers;
+ var content = new StringContent(string.Empty);
var type = representation.GetType();
// act
using (var stream = new MemoryStream())
{
- mediaFormatter.WriteToStream(type, representation, stream, contentHeaders);
+ mediaFormatter.WriteToStream(type, representation, stream, content);
stream.Seek(0, SeekOrigin.Begin);
var serialisedResult = new StreamReader(stream).ReadToEnd();
@@ -49,13 +49,13 @@ public void organisation_list_get_json_test()
{
// arrange
var mediaFormatter = new JsonHalMediaTypeFormatter { Indent = true };
- var contentHeaders = new StringContent(string.Empty).Headers;
+ var content = new StringContent(string.Empty);
var type = representation.GetType();
// act
using (var stream = new MemoryStream())
{
- mediaFormatter.WriteToStreamAsync(type, representation, stream, contentHeaders, null).Wait();
+ mediaFormatter.WriteToStreamAsync(type, representation, stream, content, null).Wait();
stream.Seek(0, SeekOrigin.Begin);
var serialisedResult = new StreamReader(stream).ReadToEnd();
View
8 WebApi.Hal.Tests/HalResourceTest.cs
@@ -22,13 +22,13 @@ public void organisation_get_json_test()
{
// arrange
var mediaFormatter = new JsonHalMediaTypeFormatter { Indent = true };
- var contentHeaders = new StringContent(string.Empty).Headers;
+ var content = new StringContent(string.Empty);
var type = resource.GetType();
// act
using (var stream = new MemoryStream())
{
- mediaFormatter.WriteToStreamAsync(type, resource, stream, contentHeaders, null);
+ mediaFormatter.WriteToStreamAsync(type, resource, stream, content, null);
stream.Seek(0, SeekOrigin.Begin);
var serialisedResult = new StreamReader(stream).ReadToEnd();
@@ -43,13 +43,13 @@ public void organisation_get_xml_test()
{
// arrange
var mediaFormatter = new XmlHalMediaTypeFormatter();
- var contentHeaders = new StringContent(string.Empty).Headers;
+ var content = new StringContent(string.Empty);
var type = resource.GetType();
// act
using (var stream = new MemoryStream())
{
- mediaFormatter.WriteToStreamAsync(type, resource, stream, contentHeaders, null);
+ mediaFormatter.WriteToStreamAsync(type, resource, stream, content, null);
stream.Seek(0, SeekOrigin.Begin);
var serialisedResult = new StreamReader(stream).ReadToEnd();
View
8 WebApi.Hal.Tests/HalResourceWithPeopleTest.cs
@@ -22,13 +22,13 @@ public void organisation_get_json_test()
{
// arrange
var mediaFormatter = new JsonHalMediaTypeFormatter { Indent = true };
- var contentHeaders = new StringContent(string.Empty).Headers;
+ var content = new StringContent(string.Empty);
var type = resource.GetType();
// act
using (var stream = new MemoryStream())
{
- mediaFormatter.WriteToStreamAsync(type, resource, stream, contentHeaders, null).Wait();
+ mediaFormatter.WriteToStreamAsync(type, resource, stream, content, null).Wait();
stream.Seek(0, SeekOrigin.Begin);
var serialisedResult = new StreamReader(stream).ReadToEnd();
@@ -43,13 +43,13 @@ public void organisation_get_xml_test()
{
// arrange
var mediaFormatter = new XmlHalMediaTypeFormatter();
- var contentHeaders = new StringContent(string.Empty).Headers;
+ var content = new StringContent(string.Empty);
var type = resource.GetType();
// act
using (var stream = new MemoryStream())
{
- mediaFormatter.WriteToStreamAsync(type, resource, stream, contentHeaders, null);
+ mediaFormatter.WriteToStreamAsync(type, resource, stream, content, null);
stream.Seek(0, SeekOrigin.Begin);
var serialisedResult = new StreamReader(stream).ReadToEnd();
View
19 WebApi.Hal/WebApi.Hal.csproj
@@ -32,14 +32,25 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Newtonsoft.Json">
- <HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
+ <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
- <Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.20710.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.WebRequest, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
+ </Reference>
<Reference Include="System.Web" />
+ <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll</HintPath>
+ </Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
View
5 WebApi.Hal/XmlHalMediaTypeFormatter.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Reflection;
@@ -19,7 +20,7 @@ public XmlHalMediaTypeFormatter()
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/hal+xml"));
}
- public override object ReadFromStream(Type type, Stream stream, HttpContentHeaders contentHeaders, IFormatterLogger formatterLogger)
+ public override object ReadFromStream(Type type, Stream stream, HttpContent content, IFormatterLogger formatterLogger)
{
if (!typeof(Representation).IsAssignableFrom(type))
{
@@ -30,7 +31,7 @@ public override object ReadFromStream(Type type, Stream stream, HttpContentHeade
return ReadHalResource(type, xml);
}
- public override void WriteToStream(Type type, object value, Stream stream, HttpContentHeaders contentHeaders)
+ public override void WriteToStream(Type type, object value, Stream stream, HttpContent content)
{
var resource = value as Representation;
if (resource == null)
View
5 WebApi.Hal/packages.config
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="4.5.7" />
+ <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net40" />
+ <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net40" />
+ <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
+ <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
</packages>
Something went wrong with that request. Please try again.