diff --git a/Nancy.Rdf.sln b/Nancy.Rdf.sln
index 9024235..859eb19 100644
--- a/Nancy.Rdf.sln
+++ b/Nancy.Rdf.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nancy.Rdf", "src\Nancy.Rdf\Nancy.Rdf.csproj", "{D789D63C-821B-410B-A953-DFEBCBFC9D40}"
EndProject
diff --git a/Nancy.Rdf.sln.DotSettings b/Nancy.Rdf.sln.DotSettings
index 0953e63..e7f7408 100644
--- a/Nancy.Rdf.sln.DotSettings
+++ b/Nancy.Rdf.sln.DotSettings
@@ -1,3 +1,5 @@
+ DO_NOT_SHOW
+ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
<data><IncludeFilters /><ExcludeFilters><Filter ModuleMask="*.Tests" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /></ExcludeFilters></data>
<data />
\ No newline at end of file
diff --git a/paket.dependencies b/paket.dependencies
index e4f702e..eaf160a 100644
--- a/paket.dependencies
+++ b/paket.dependencies
@@ -1,15 +1,13 @@
source https://nuget.org/api/v2
-source https://ci.appveyor.com/nuget/jsonld-entities-aavhsnxi7xjp
content: none
redirects: on
-framework: net40, net45
+framework: net452
-nuget Nancy
nuget newtonsoft.json
nuget dotNetRDF
nuget json-ld.net
-nuget Nancy
+nuget Nancy >= 2 prerelease
nuget GitVersionTask
nuget HtmlAgilityPack
nuget OpenCover
@@ -20,10 +18,13 @@ nuget StyleCop.Analyzers
nuget GitLink
nuget JsonLd.Entities prerelease
nuget Nullguard.Fody
-nuget Nancy.Testing
+nuget Nancy.Testing >= 2 prerelease
nuget FluentAssertions
nuget JetbrainsAnnotations.Fody
-nuget Nancy.Owin
+nuget Nancy.Owin >= 2 prerelease
nuget Microsoft.Owin.Host.SystemWeb
nuget Microsoft.Owin.Hosting
-nuget Rdf.Vocabularies
\ No newline at end of file
+nuget Rdf.Vocabularies
+
+group code-analysis
+gist tpluscode/a285267d2543466fc35c3a168c846f9f
\ No newline at end of file
diff --git a/paket.lock b/paket.lock
index d051ecb..b5ce8f7 100644
--- a/paket.lock
+++ b/paket.lock
@@ -1,24 +1,29 @@
REDIRECTS: ON
CONTENT: NONE
-FRAMEWORK: NET40, NET45
+FRAMEWORK: NET452
NUGET
remote: https://www.nuget.org/api/v2
- specs:
- CsQuery (1.3.4)
- dotNetRDF (1.0.9.3683)
+ AngleSharp (0.9.9)
+ dotNetRDF (1.0.12)
HtmlAgilityPack (>= 1.4.9)
- Newtonsoft.Json (>= 6.0.8)
- VDS.Common (1.6)
- FakeItEasy (2.0)
- FluentAssertions (4.6.3)
+ Newtonsoft.Json (>= 8.0.3)
+ VDS.Common (1.6.4)
+ FakeItEasy (2.3.1)
+ FluentAssertions (4.17)
Fody (1.29.4)
- gitlink (2.2)
- GitVersionTask (3.5.4)
- HtmlAgilityPack (1.4.9)
- JetBrainsAnnotations.Fody (1.0.4)
+ gitlink (2.3)
+ GitVersionTask (3.6.4)
+ HtmlAgilityPack (1.4.9.5)
+ JetBrainsAnnotations.Fody (1.0.5)
Fody (>= 1.29.2)
+ JsonLd.Entities (0.3.3)
+ json-ld.net (>= 1.0.5)
json-ld.net (1.0.5)
Newtonsoft.Json (>= 6.0.4)
+ Microsoft.DotNet.PlatformAbstractions (1.1)
+ Microsoft.Extensions.DependencyModel (1.1)
+ Microsoft.DotNet.PlatformAbstractions (>= 1.1)
+ Newtonsoft.Json (>= 9.0.1)
Microsoft.Owin (3.0.1)
Owin (>= 1.0)
Microsoft.Owin.Host.SystemWeb (3.0.1)
@@ -27,14 +32,18 @@ NUGET
Microsoft.Owin.Hosting (3.0.1)
Microsoft.Owin (>= 3.0.1)
Owin (>= 1.0)
- Nancy (1.4.3)
- Nancy.Owin (1.4.1)
- Nancy (>= 1.4.1)
+ Nancy (2.0.0-barneyrubble)
+ Microsoft.Extensions.DependencyModel (>= 1.0)
+ Nancy.Authentication.Forms (2.0.0-barneyrubble)
+ Nancy (>= 2.0.0-barneyrubble)
+ Nancy.Owin (2.0.0-barneyrubble)
+ Nancy (>= 2.0.0-barneyrubble)
Owin (>= 1.0)
- Nancy.Testing (1.4.1)
- CsQuery (>= 1.3.3)
- Nancy (>= 1.4.1)
- Newtonsoft.Json (8.0.3)
+ Nancy.Testing (2.0.0-barneyrubble)
+ AngleSharp (>= 0.9.5)
+ Nancy (>= 2.0.0-barneyrubble)
+ Nancy.Authentication.Forms (>= 2.0.0-barneyrubble)
+ Newtonsoft.Json (9.0.1)
NullGuard.Fody (1.4.6)
Fody (>= 1.29.2)
NUnit (2.6.4)
@@ -43,8 +52,10 @@ NUGET
Rdf.Vocabularies (1.1.1)
SpecFlow (2.1)
StyleCop.Analyzers (1.0)
- VDS.Common (1.6)
- remote: https://ci.appveyor.com/nuget/jsonld-entities-aavhsnxi7xjp
- specs:
- JsonLD.Entities (0.3.3)
- json-ld.net
+ VDS.Common (1.6.4)
+
+GROUP code-analysis
+
+GIST
+ remote: tpluscode/a285267d2543466fc35c3a168c846f9f
+ FULLPROJECT (c9b7a831e53e929f2ecce09b14a61e28007b669f)
\ No newline at end of file
diff --git a/src/Example/Nancy.Rdf.Sample/Nancy.Rdf.Sample.csproj b/src/Example/Nancy.Rdf.Sample/Nancy.Rdf.Sample.csproj
index b04a84c..fa0f0be 100644
--- a/src/Example/Nancy.Rdf.Sample/Nancy.Rdf.Sample.csproj
+++ b/src/Example/Nancy.Rdf.Sample/Nancy.Rdf.Sample.csproj
@@ -13,7 +13,7 @@
Properties
Nancy.Rdf.Sample
Nancy.Rdf.Sample
- v4.5
+ v4.5.2
true
@@ -54,9 +54,9 @@
-
+
@@ -118,10 +118,21 @@
-->
-
+
+
+
+ ..\..\..\packages\json-ld.net\lib\net40-client\json-ld.net.dll
+ True
+ True
+
+
+
+
+
+
- ..\..\..\packages\JsonLD.Entities\lib\net40\JsonLD.Entities.dll
+ ..\..\..\packages\JsonLd.Entities\lib\net40\JsonLD.Entities.dll
True
True
@@ -129,10 +140,10 @@
-
+
-
- ..\..\..\packages\json-ld.net\lib\net40-client\json-ld.net.dll
+
+ ..\..\..\packages\Microsoft.DotNet.PlatformAbstractions\lib\net451\Microsoft.DotNet.PlatformAbstractions.dll
True
True
@@ -140,7 +151,18 @@
-
+
+
+
+ ..\..\..\packages\Microsoft.Extensions.DependencyModel\lib\net451\Microsoft.Extensions.DependencyModel.dll
+ True
+ True
+
+
+
+
+
+
..\..\..\packages\Microsoft.Owin\lib\net45\Microsoft.Owin.dll
@@ -151,7 +173,7 @@
-
+
..\..\..\packages\Microsoft.Owin.Host.SystemWeb\lib\net45\Microsoft.Owin.Host.SystemWeb.dll
@@ -162,7 +184,7 @@
-
+
..\..\..\packages\Microsoft.Owin.Hosting\lib\net45\Microsoft.Owin.Hosting.dll
@@ -173,10 +195,10 @@
-
+
- ..\..\..\packages\Nancy\lib\net40\Nancy.dll
+ ..\..\..\packages\Nancy\lib\net452\Nancy.dll
True
True
@@ -184,10 +206,10 @@
-
+
- ..\..\..\packages\Nancy.Owin\lib\net40\Nancy.Owin.dll
+ ..\..\..\packages\Nancy.Owin\lib\net452\Nancy.Owin.dll
True
True
@@ -195,16 +217,7 @@
-
-
-
- ..\..\..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll
- True
- True
-
-
-
-
+
..\..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll
@@ -215,7 +228,7 @@
-
+
..\..\..\packages\Owin\lib\net40\Owin.dll
@@ -226,7 +239,7 @@
-
+
..\..\..\packages\Rdf.Vocabularies\lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\Rdf.Vocabularies.dll
diff --git a/src/Example/Nancy.Rdf.Sample/Startup.cs b/src/Example/Nancy.Rdf.Sample/Startup.cs
index a76fca5..8e9c18e 100644
--- a/src/Example/Nancy.Rdf.Sample/Startup.cs
+++ b/src/Example/Nancy.Rdf.Sample/Startup.cs
@@ -1,4 +1,5 @@
using System;
+using JsonLD.Entities;
using JsonLD.Entities.Context;
using Microsoft.Owin;
using Nancy.Rdf.Sample;
@@ -30,6 +31,8 @@ public class Person
public DateTime DateOfBirth { get; set; }
+ public string Friend { get; set; }
+
[JsonProperty]
private string Type
{
@@ -55,16 +58,17 @@ public class PersonModule : NancyModule
{
public PersonModule()
{
- Get["person/{id}"] = _ =>
+ Get("person/{id}", _ =>
{
return new Person
{
Id = "http://api.guru/person/" + _.id,
Name = "John",
LastName = "Doe",
- DateOfBirth = new DateTime(1967, 8, 2)
+ DateOfBirth = new DateTime(1967, 8, 2),
+ Friend = ("http://api.guru/person/" + _.id + 10)
};
- };
+ });
}
}
diff --git a/src/Example/Nancy.Rdf.Sample/Web.config b/src/Example/Nancy.Rdf.Sample/Web.config
index 814ffee..fa702b4 100644
--- a/src/Example/Nancy.Rdf.Sample/Web.config
+++ b/src/Example/Nancy.Rdf.Sample/Web.config
@@ -13,7 +13,7 @@
-->
-
+
@@ -22,10 +22,16 @@
+
+
+ True
+
+
+
True
-
+
\ No newline at end of file
diff --git a/src/Nancy.Rdf.Tests/AcceptHeaderCoercion.feature.cs b/src/Nancy.Rdf.Tests/AcceptHeaderCoercion.feature.cs
index cbba052..16a344e 100644
--- a/src/Nancy.Rdf.Tests/AcceptHeaderCoercion.feature.cs
+++ b/src/Nancy.Rdf.Tests/AcceptHeaderCoercion.feature.cs
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
//
// This code was generated by SpecFlow (http://www.specflow.org/).
-// SpecFlow Version:2.0.0.0
+// SpecFlow Version:2.1.0.0
// SpecFlow Generator Version:2.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
@@ -15,7 +15,7 @@ namespace Nancy.Rdf.Tests
using TechTalk.SpecFlow;
- [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.0.0.0")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.1.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Accept Header Coercion")]
@@ -31,7 +31,7 @@ public partial class AcceptHeaderCoercionFeature
public virtual void FeatureSetup()
{
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
- TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Accept Header Coercion", "\tTo be more dev-friendly\r\n\tI want default to return Rdf from routes by default", ProgrammingLanguage.CSharp, ((string[])(null)));
+ TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Accept Header Coercion", "\tTo be more dev-friendly\r\n\tI want default to return RDF from routes by default", ProgrammingLanguage.CSharp, ((string[])(null)));
testRunner.OnFeatureStart(featureInfo);
}
diff --git a/src/Nancy.Rdf.Tests/App.config b/src/Nancy.Rdf.Tests/App.config
index 6431d52..6ecbd95 100644
--- a/src/Nancy.Rdf.Tests/App.config
+++ b/src/Nancy.Rdf.Tests/App.config
@@ -7,10 +7,6 @@
-
-
-
-
@@ -27,10 +23,20 @@
+
+ True
+
+
+
+
+ True
+
+
+
True
-
+
-
+
diff --git a/src/Nancy.Rdf.Tests/Bindings/AcceptHeaderCoercionSteps.cs b/src/Nancy.Rdf.Tests/Bindings/AcceptHeaderCoercionSteps.cs
index 23024ed..d48e073 100644
--- a/src/Nancy.Rdf.Tests/Bindings/AcceptHeaderCoercionSteps.cs
+++ b/src/Nancy.Rdf.Tests/Bindings/AcceptHeaderCoercionSteps.cs
@@ -11,37 +11,37 @@ namespace Nancy.Rdf.Tests.Bindings
[Binding]
public class AcceptHeaderCoercionSteps
{
- private CoerceAcceptHeaders _convention;
- private IEnumerable> _coercedAcceptHeaders;
+ private CoerceAcceptHeaders convention;
+ private IEnumerable> coercedAcceptHeaders;
[Given(@"default convention")]
public void GivenDefaultConvention()
{
- _convention = AcceptHeaderConventions.CoerceBlankAcceptHeader();
+ this.convention = AcceptHeaderConventions.CoerceBlankAcceptHeader();
}
[Given(@"convention set to return json-ld")]
public void GivenConventionSetToReturn()
{
- _convention = AcceptHeaderConventions.CoerceBlankAcceptHeader(RdfSerialization.JsonLd);
+ this.convention = AcceptHeaderConventions.CoerceBlankAcceptHeader(RdfSerialization.JsonLd);
}
[When(@"invoke the convention with empty header collection")]
public void WhenInvokeTheConvention()
{
- _coercedAcceptHeaders = _convention(new Tuple[0], new NancyContext());
+ this.coercedAcceptHeaders = this.convention(new Tuple[0], new NancyContext());
}
[When(@"invoke the convention with non-empty header collection")]
public void WhenInvokeTheConventionWithExistingHeader()
{
- _coercedAcceptHeaders = _convention(new[] { Tuple.Create("text/html", 0.9m) }, new NancyContext());
+ this.coercedAcceptHeaders = this.convention(new[] { Tuple.Create("text/html", 0.9m) }, new NancyContext());
}
[Then(@"Accept header should be '(.*)', '(.*)'")]
public void ThenAcceptHeaderShouldBe(string mediaType, decimal weight)
{
- Assert.That(_coercedAcceptHeaders.Single(), Is.EqualTo(Tuple.Create(mediaType, weight)));
+ Assert.That(this.coercedAcceptHeaders.Single(), Is.EqualTo(Tuple.Create(mediaType, weight)));
}
}
}
diff --git a/src/Nancy.Rdf.Tests/Bindings/ContentNegotiationSteps.cs b/src/Nancy.Rdf.Tests/Bindings/ContentNegotiationSteps.cs
index fb74581..011500d 100644
--- a/src/Nancy.Rdf.Tests/Bindings/ContentNegotiationSteps.cs
+++ b/src/Nancy.Rdf.Tests/Bindings/ContentNegotiationSteps.cs
@@ -11,34 +11,34 @@ namespace Nancy.Rdf.Tests.Bindings
[Binding]
public class ContentNegotiationSteps
{
- private readonly ISerializer _serializer;
- private MediaRange _mediaRange;
- private Response _response;
+ private readonly ISerializer serializer;
+ private MediaRange mediaRange;
+ private Response response;
public ContentNegotiationSteps()
{
- _serializer = A.Fake();
- A.CallTo(() => _serializer.CanSerialize(A._)).Returns(true);
+ this.serializer = A.Fake();
+ A.CallTo(() => this.serializer.CanSerialize(A._)).Returns(true);
}
[Given(@"requested media range '(.*)'")]
public void GivenRequestedMediaRange(string mediaRange)
{
- _mediaRange = new MediaRange(mediaRange);
+ this.mediaRange = new MediaRange(mediaRange);
}
[When(@"processing model"), Scope(Tag = "Rdf")]
public void WhenProcessingRdfModel()
{
- var processor = new RdfResponseProcessorTestable(new[] { _serializer });
+ var processor = new RdfResponseProcessorTestable(new[] { this.serializer });
- _response = processor.Process(_mediaRange, new object(), new NancyContext());
+ this.response = processor.Process(this.mediaRange, new object(), new NancyContext());
}
[Then(@"response should have status '(.*)'")]
public void ThenResponseShouldHaveStatus(string expectedStatusCode)
{
- Assert.That(_response.StatusCode, Is.EqualTo(Enum.Parse(typeof(HttpStatusCode), expectedStatusCode)));
+ Assert.That(this.response.StatusCode, Is.EqualTo(Enum.Parse(typeof(HttpStatusCode), expectedStatusCode)));
}
private class RdfResponseProcessorTestable : RdfResponseProcessor
diff --git a/src/Nancy.Rdf.Tests/Bindings/GraphSetup.cs b/src/Nancy.Rdf.Tests/Bindings/GraphSetup.cs
index 693f439..6774de2 100644
--- a/src/Nancy.Rdf.Tests/Bindings/GraphSetup.cs
+++ b/src/Nancy.Rdf.Tests/Bindings/GraphSetup.cs
@@ -7,17 +7,17 @@ namespace Nancy.Rdf.Tests.Bindings
[Binding]
public class GraphSetup
{
- private readonly IObjectContainer _container;
+ private readonly IObjectContainer container;
public GraphSetup(IObjectContainer container)
{
- _container = container;
+ this.container = container;
}
[BeforeScenario]
public void InitializeGraph()
{
- _container.RegisterInstanceAs(new Graph());
+ this.container.RegisterInstanceAs(new Graph());
}
}
}
diff --git a/src/Nancy.Rdf.Tests/Bindings/JsonLdSerializationSteps.cs b/src/Nancy.Rdf.Tests/Bindings/JsonLdSerializationSteps.cs
index 7fc10e9..83e349e 100644
--- a/src/Nancy.Rdf.Tests/Bindings/JsonLdSerializationSteps.cs
+++ b/src/Nancy.Rdf.Tests/Bindings/JsonLdSerializationSteps.cs
@@ -1,4 +1,4 @@
-using System.IO;
+using System.IO;
using FakeItEasy;
using Nancy.Rdf.Contexts;
using Nancy.Rdf.Responses;
@@ -11,27 +11,27 @@ namespace Nancy.Rdf.Tests.Bindings
[Binding, Scope(Tag = "JsonLd")]
public class JsonLdSerializationSteps
{
- private readonly ISerializer _serializer;
- private readonly SerializationContext _context;
+ private readonly ISerializer serializer;
+ private readonly SerializationContext context;
public JsonLdSerializationSteps(SerializationContext context)
{
- _context = context;
- _serializer = new JsonLdSerializer(_context.Serializer, A.Dummy());
+ this.context = context;
+ this.serializer = new JsonLdSerializer(this.context.Serializer, A.Dummy());
}
[When(@"model is serialized"), Scope(Tag = "JsonLd")]
public void WhenModelIsSerializedTo()
{
- var contentType = _context.AcceptHeader ?? RdfSerialization.JsonLd.MediaType;
- _serializer.Serialize(contentType, new object(), _context.OutputStream);
+ var contentType = this.context.AcceptHeader ?? RdfSerialization.JsonLd.MediaType;
+ this.serializer.Serialize(contentType, new object(), this.context.OutputStream);
- _context.OutputStream.Seek(0, SeekOrigin.Begin);
- using (var streamReader = new StreamReader(_context.OutputStream))
+ this.context.OutputStream.Seek(0, SeekOrigin.Begin);
+ using (var streamReader = new StreamReader(this.context.OutputStream))
{
using (var jsonTextReader = new JsonTextReader(streamReader))
{
- _context.Result = JToken.ReadFrom(jsonTextReader);
+ this.context.Result = JToken.ReadFrom(jsonTextReader);
}
}
}
diff --git a/src/Nancy.Rdf.Tests/Bindings/ModelSerializingSteps.cs b/src/Nancy.Rdf.Tests/Bindings/ModelSerializingSteps.cs
index a7f484e..9389863 100644
--- a/src/Nancy.Rdf.Tests/Bindings/ModelSerializingSteps.cs
+++ b/src/Nancy.Rdf.Tests/Bindings/ModelSerializingSteps.cs
@@ -1,4 +1,4 @@
-using FakeItEasy;
+using FakeItEasy;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using TechTalk.SpecFlow;
@@ -8,30 +8,30 @@ namespace Nancy.Rdf.Tests.Bindings
[Binding]
public class ModelSerializingSteps
{
- private readonly SerializationContext _context;
+ private readonly SerializationContext context;
protected ModelSerializingSteps(SerializationContext context)
{
- _context = context;
+ this.context = context;
}
[Given(@"A serialized model:")]
public void GivenASerializedModel(string json)
{
- A.CallTo(() => _context.Serializer.Serialize(A
-
+
-
- ..\..\packages\CsQuery\lib\net40\CsQuery.dll
+
+ ..\..\packages\AngleSharp\lib\net45\AngleSharp.dll
True
True
@@ -127,7 +134,7 @@
-
+
..\..\packages\dotNetRDF\lib\net40\dotNetRDF.dll
@@ -138,7 +145,7 @@
-
+
..\..\packages\FakeItEasy\lib\net40\FakeItEasy.dll
@@ -149,29 +156,26 @@
-
+
- ..\..\packages\FluentAssertions\lib\net40\FluentAssertions.Core.dll
+ ..\..\packages\FluentAssertions\lib\net45\FluentAssertions.Core.dll
True
True
- ..\..\packages\FluentAssertions\lib\net40\FluentAssertions.dll
+ ..\..\packages\FluentAssertions\lib\net45\FluentAssertions.dll
True
True
-
+
+
+
-
- ..\..\packages\FluentAssertions\lib\net45\FluentAssertions.Core.dll
- True
- True
-
-
- ..\..\packages\FluentAssertions\lib\net45\FluentAssertions.dll
+
+ ..\..\packages\HtmlAgilityPack\lib\Net45\HtmlAgilityPack.dll
True
True
@@ -179,19 +183,21 @@
-
+
-
- ..\..\packages\HtmlAgilityPack\lib\Net40\HtmlAgilityPack.dll
+
+ ..\..\packages\JetBrainsAnnotations.Fody\Lib\JetBrains.Annotations.dll
True
True
-
+
+
+
-
- ..\..\packages\HtmlAgilityPack\lib\Net45\HtmlAgilityPack.dll
+
+ ..\..\packages\json-ld.net\lib\net40-client\json-ld.net.dll
True
True
@@ -199,10 +205,10 @@
-
+
-
- ..\..\packages\JetBrainsAnnotations.Fody\Lib\JetBrains.Annotations.dll
+
+ ..\..\packages\JsonLd.Entities\lib\net40\JsonLD.Entities.dll
True
True
@@ -210,10 +216,10 @@
-
+
-
- ..\..\packages\JsonLD.Entities\lib\net40\JsonLD.Entities.dll
+
+ ..\..\packages\Microsoft.DotNet.PlatformAbstractions\lib\net451\Microsoft.DotNet.PlatformAbstractions.dll
True
True
@@ -221,10 +227,10 @@
-
+
-
- ..\..\packages\json-ld.net\lib\net40-client\json-ld.net.dll
+
+ ..\..\packages\Microsoft.Extensions.DependencyModel\lib\net451\Microsoft.Extensions.DependencyModel.dll
True
True
@@ -232,10 +238,10 @@
-
+
- ..\..\packages\Nancy\lib\net40\Nancy.dll
+ ..\..\packages\Nancy\lib\net452\Nancy.dll
True
True
@@ -243,10 +249,10 @@
-
+
-
- ..\..\packages\Nancy.Testing\lib\net40\Nancy.Testing.dll
+
+ ..\..\packages\Nancy.Authentication.Forms\lib\net452\Nancy.Authentication.Forms.dll
True
True
@@ -254,16 +260,18 @@
-
+
-
- ..\..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll
+
+ ..\..\packages\Nancy.Testing\lib\net452\Nancy.Testing.dll
True
True
-
+
+
+
..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll
@@ -274,7 +282,7 @@
-
+
..\..\packages\NUnit\lib\nunit.framework.dll
@@ -285,7 +293,7 @@
-
+
..\..\packages\Rdf.Vocabularies\lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\Rdf.Vocabularies.dll
@@ -296,7 +304,7 @@
-
+
..\..\packages\SpecFlow\lib\net45\TechTalk.SpecFlow.dll
@@ -320,7 +328,7 @@
-
+
..\..\packages\VDS.Common\lib\net40-client\VDS.Common.dll
diff --git a/src/Nancy.Rdf.Tests/RdfResponseProcessorTests.cs b/src/Nancy.Rdf.Tests/RdfResponseProcessorTests.cs
index ceb6878..fb1f9bb 100644
--- a/src/Nancy.Rdf.Tests/RdfResponseProcessorTests.cs
+++ b/src/Nancy.Rdf.Tests/RdfResponseProcessorTests.cs
@@ -17,14 +17,14 @@ public class RdfResponseProcessorTests
static RdfResponseProcessorTests()
{
+ var path = new Url("http://example.com/api/test")
+ {
+ BasePath = "api"
+ };
+
NancyContext = new NancyContext
{
- Request = new Request(
- "GET",
- new Url("http://example.com/api/test")
- {
- BasePath = "api"
- })
+ Request = new Request("GET", path)
};
}
@@ -48,7 +48,7 @@ public void Should_match_wildcard_when_set_up()
{
// given
var serializer = A.Fake();
- A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
+ A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
var nancyContext = new NancyContext();
nancyContext.Items.Add(FallbackSerializationKey, RdfSerialization.RdfXml);
var processor = new RdfResponseProcessorTestable(new[] { serializer });
@@ -66,7 +66,7 @@ public void Should_not_match_wildcard_when_another_fallback_set_up()
{
// given
var serializer = A.Fake();
- A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
+ A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
var nancyContext = new NancyContext();
nancyContext.Items.Add(FallbackSerializationKey, RdfSerialization.Turtle);
var processor = new RdfResponseProcessorTestable(new[] { serializer });
@@ -84,7 +84,7 @@ public void Should_not_match_wildcard_when_not_set_up()
{
// given
var serializer = A.Fake();
- A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
+ A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
var processor = new RdfResponseProcessorTestable(new[] { serializer });
// when
@@ -100,7 +100,7 @@ public void Should_pass_SiteBase_from_context_to_serializtion()
{
// given
var serializer = A.Fake();
- A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
+ A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
var processor = new RdfResponseProcessorTestable(new[] { serializer });
// when
@@ -109,7 +109,7 @@ public void Should_pass_SiteBase_from_context_to_serializtion()
// then
A.CallTo(() => serializer.Serialize(
- RdfSerialization.RdfXml.MediaType,
+ A.That.Matches(mr => mr == RdfSerialization.RdfXml.MediaType),
A.That.Matches(wm => wm.BaseUrl == new Uri(NancyContext.Request.Url.SiteBase)),
A._)).MustHaveHappened();
}
@@ -118,9 +118,9 @@ public void Should_pass_SiteBase_from_context_to_serializtion()
public void Should_pass_actual_requested()
{
// given
- const string contentType = "application/rdf+xml;profile=testprofile";
+ var contentType = new MediaRange("application/rdf+xml;profile=testprofile");
var serializer = A.Fake();
- A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
+ A.CallTo(() => serializer.CanSerialize(A.Ignored)).Returns(true);
var processor = new RdfResponseProcessorTestable(new[] { serializer });
// when
@@ -128,7 +128,23 @@ public void Should_pass_actual_requested()
response.Contents(new MemoryStream());
// then
- A.CallTo(() => serializer.Serialize(contentType, A._, A._)).MustHaveHappened();
+ A.CallTo(() => serializer.Serialize(
+ A.That.Matches(mr => mr.Equals(contentType)),
+ A._,
+ A._)).MustHaveHappened();
+ }
+
+ [Test]
+ public void CanProcess_Should_not_match_model_is_null()
+ {
+ // given
+ var processor = new RdfResponseProcessorTestable(new ISerializer[0]);
+
+ // when
+ var match = processor.CanProcess(new MediaRange(RdfSerialization.RdfXml.MediaType), null, new NancyContext());
+
+ // then
+ Assert.That(match.ModelResult, Is.EqualTo(MatchResult.NoMatch));
}
private class RdfResponseProcessorTestable : RdfResponseProcessor
diff --git a/src/Nancy.Rdf.Tests/Serializing/RdfSerializerTests.cs b/src/Nancy.Rdf.Tests/Serializing/RdfSerializerTests.cs
index ff995d5..b02d749 100644
--- a/src/Nancy.Rdf.Tests/Serializing/RdfSerializerTests.cs
+++ b/src/Nancy.Rdf.Tests/Serializing/RdfSerializerTests.cs
@@ -15,22 +15,22 @@ namespace Nancy.Rdf.Tests.Serializing
[TestFixture]
public class RdfSerializerTests
{
- private RdfSerializerTestable _serializer;
- private IEntitySerializer _entitySerializer;
- private INodeFactory _nodeFactory = new NodeFactory();
+ private RdfSerializerTestable serializer;
+ private IEntitySerializer entitySerializer;
+ private INodeFactory nodeFactory = new NodeFactory();
[SetUp]
public void Setup()
{
- _entitySerializer = A.Fake();
- _serializer = new RdfSerializerTestable(_entitySerializer);
+ this.entitySerializer = A.Fake();
+ this.serializer = new RdfSerializerTestable(this.entitySerializer);
}
[Test]
public void Should_serialize_bool_with_proper_format()
{
// given
- A.CallTo(() => _entitySerializer.Serialize(A._, A._))
+ A.CallTo(() => this.entitySerializer.Serialize(A._, A._))
.Returns(JObject.Parse(@"{
'@context':
{
@@ -43,10 +43,10 @@ public void Should_serialize_bool_with_proper_format()
}"));
// when
- _serializer.Serialize("text/turtle", new object(), new MemoryStream());
+ this.serializer.Serialize("text/turtle", new object(), new MemoryStream());
// then
- Assert.That(_serializer.Triples.Any(triple =>
+ Assert.That(this.serializer.Triples.Any(triple =>
{
var valueMatches = ((LiteralNode)triple.Object).Value == "true";
var dataTypeMatches = ((LiteralNode)triple.Object).DataType == new Uri(Xsd.boolean);
@@ -59,7 +59,7 @@ public void Should_serialize_bool_with_proper_format()
public void Should_serialize_datetime_with_proper_format()
{
// given
- A.CallTo(() => _entitySerializer.Serialize(A._, A._))
+ A.CallTo(() => this.entitySerializer.Serialize(A._, A._))
.Returns(JObject.Parse(@"{
'@context':
{
@@ -72,10 +72,10 @@ public void Should_serialize_datetime_with_proper_format()
}"));
// when
- _serializer.Serialize("text/turtle", new object(), new MemoryStream());
+ this.serializer.Serialize("text/turtle", new object(), new MemoryStream());
// then
- Assert.That(_serializer.Triples.Any(triple =>
+ Assert.That(this.serializer.Triples.Any(triple =>
{
var valueMatches = ((LiteralNode)triple.Object).Value == "2016-03-21T00:00:00";
var dataTypeMatches = ((LiteralNode)triple.Object).DataType == new Uri(Xsd.dateTime);
@@ -88,20 +88,20 @@ public void Should_serialize_datetime_with_proper_format()
public void Should_serialize_correct_relative_URIs_according_to_base()
{
// given
- A.CallTo(() => _entitySerializer.Serialize(A._, A._))
+ A.CallTo(() => this.entitySerializer.Serialize(A._, A._))
.Returns(JObject.Parse(@"{
'@id': 'some/id',
'http://example.com/property': { '@id': 'some/relative/path' }
}"));
// when
- _serializer.Serialize("text/turtle", new WrappedModel(new object(), "http://example.api/site"), new MemoryStream());
+ this.serializer.Serialize("text/turtle", new WrappedModel(new object(), "http://example.api/site"), new MemoryStream());
// then
- Assert.That(_serializer.Triples.Contains(new Triple(
- _nodeFactory.CreateUriNode(new Uri("http://example.api/site/some/id")),
- _nodeFactory.CreateUriNode(new Uri("http://example.com/property")),
- _nodeFactory.CreateUriNode(new Uri("http://example.api/site/some/relative/path")))));
+ Assert.That(this.serializer.Triples.Contains(new Triple(
+ this.nodeFactory.CreateUriNode(new Uri("http://example.api/site/some/id")),
+ this.nodeFactory.CreateUriNode(new Uri("http://example.com/property")),
+ this.nodeFactory.CreateUriNode(new Uri("http://example.api/site/some/relative/path")))));
}
private class RdfSerializerTestable : RdfSerializer
@@ -109,14 +109,14 @@ private class RdfSerializerTestable : RdfSerializer
public RdfSerializerTestable(IEntitySerializer entitySerializer)
: base(RdfSerialization.Turtle, entitySerializer)
{
- Triples = new List();
+ this.Triples = new List();
}
public IList Triples { get; set; }
protected override void WriteRdf(StreamWriter writer, IEnumerable triples)
{
- Triples = triples.ToList();
+ this.Triples = triples.ToList();
}
}
}
diff --git a/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature b/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature
index 516af1b..be5cccd 100644
--- a/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature
+++ b/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature
@@ -28,7 +28,7 @@ Scenario: Should pass through serialized model
@Brochure
@JsonLd
-Scenario: Should allow expanded profile
+Scenario Template: Should allow expanded profile
Given A serialized model:
"""
{
@@ -39,7 +39,7 @@ Scenario: Should allow expanded profile
'title': 'Jelcz M11 - mały, stary autobus'
}
"""
- Given accepted media type 'application/ld+json; profile=http://www.w3.org/ns/json-ld#expanded'
+ Given accepted media type ''
When model is serialized
Then output stream should equal
"""
@@ -49,4 +49,8 @@ Scenario: Should allow expanded profile
'@value': 'Jelcz M11 - mały, stary autobus'
}]
}]
- """
\ No newline at end of file
+ """
+Examples:
+ | mediaType |
+ | application/ld+json; profile="http://www.w3.org/ns/json-ld#expanded" |
+ | application/ld+json; profile=http://www.w3.org/ns/json-ld#expanded | # without quotes
\ No newline at end of file
diff --git a/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature.cs b/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature.cs
index dcc81fc..ae36b14 100644
--- a/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature.cs
+++ b/src/Nancy.Rdf.Tests/SerializingToJsonLd.feature.cs
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
//
// This code was generated by SpecFlow (http://www.specflow.org/).
-// SpecFlow Version:2.0.0.0
+// SpecFlow Version:2.1.0.0
// SpecFlow Generator Version:2.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
@@ -15,7 +15,7 @@ namespace Nancy.Rdf.Tests
using TechTalk.SpecFlow;
- [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.0.0.0")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.1.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Serializing to JSON-LD")]
@@ -94,11 +94,18 @@ public virtual void ShouldPassThroughSerializedModel()
[NUnit.Framework.DescriptionAttribute("Should allow expanded profile")]
[NUnit.Framework.CategoryAttribute("Brochure")]
[NUnit.Framework.CategoryAttribute("JsonLd")]
- public virtual void ShouldAllowExpandedProfile()
+ [NUnit.Framework.TestCaseAttribute("application/ld+json; profile=\"http://www.w3.org/ns/json-ld#expanded\"", new string[0])]
+ [NUnit.Framework.TestCaseAttribute("application/ld+json; profile=http://www.w3.org/ns/json-ld#expanded", new string[0])]
+ public virtual void ShouldAllowExpandedProfile(string mediaType, string[] exampleTags)
{
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Should allow expanded profile", new string[] {
- "Brochure",
- "JsonLd"});
+ string[] @__tags = new string[] {
+ "Brochure",
+ "JsonLd"};
+ if ((exampleTags != null))
+ {
+ @__tags = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Concat(@__tags, exampleTags));
+ }
+ TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Should allow expanded profile", @__tags);
#line 31
this.ScenarioSetup(scenarioInfo);
#line hidden
@@ -107,8 +114,7 @@ public virtual void ShouldAllowExpandedProfile()
"p://wikibus.org/brochure/12345\',\r\n\t\'title\': \'Jelcz M11 - mały, stary autobus\'\r\n}" +
"", ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 42
- testRunner.Given("accepted media type \'application/ld+json; profile=http://www.w3.org/ns/json-ld#ex" +
- "panded\'", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
+ testRunner.Given(string.Format("accepted media type \'{0}\'", mediaType), ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 43
testRunner.When("model is serialized", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
diff --git a/src/Nancy.Rdf.Tests/SerializingToRdf.feature.cs b/src/Nancy.Rdf.Tests/SerializingToRdf.feature.cs
index 7be5708..7ec068c 100644
--- a/src/Nancy.Rdf.Tests/SerializingToRdf.feature.cs
+++ b/src/Nancy.Rdf.Tests/SerializingToRdf.feature.cs
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
//
// This code was generated by SpecFlow (http://www.specflow.org/).
-// SpecFlow Version:2.0.0.0
+// SpecFlow Version:2.1.0.0
// SpecFlow Generator Version:2.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
@@ -15,10 +15,10 @@ namespace Nancy.Rdf.Tests
using TechTalk.SpecFlow;
- [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.0.0.0")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.1.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
- [NUnit.Framework.DescriptionAttribute("Serializing to Rdf")]
+ [NUnit.Framework.DescriptionAttribute("Serializing to RDF")]
public partial class SerializingToRDFFeature
{
@@ -31,7 +31,7 @@ public partial class SerializingToRDFFeature
public virtual void FeatureSetup()
{
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
- TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Serializing to Rdf", "\tTest serializing models to Rdf", ProgrammingLanguage.CSharp, ((string[])(null)));
+ TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Serializing to RDF", "\tTest serializing models to RDF", ProgrammingLanguage.CSharp, ((string[])(null)));
testRunner.OnFeatureStart(featureInfo);
}
@@ -64,12 +64,12 @@ public virtual void ScenarioCleanup()
}
[NUnit.Framework.TestAttribute()]
- [NUnit.Framework.DescriptionAttribute("Serialize simple model to Rdf")]
+ [NUnit.Framework.DescriptionAttribute("Serialize simple model to RDF")]
[NUnit.Framework.CategoryAttribute("Brochure")]
[NUnit.Framework.CategoryAttribute("Rdf")]
public virtual void SerializeSimpleModelToRDF()
{
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Serialize simple model to Rdf", new string[] {
+ TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Serialize simple model to RDF", new string[] {
"Brochure",
"Rdf"});
#line 6
diff --git a/src/Nancy.Rdf/Contexts/ContextPathMap.cs b/src/Nancy.Rdf/Contexts/ContextPathMap.cs
index dcfeb1f..df406bd 100644
--- a/src/Nancy.Rdf/Contexts/ContextPathMap.cs
+++ b/src/Nancy.Rdf/Contexts/ContextPathMap.cs
@@ -13,10 +13,11 @@ public struct ContextPathMap
///
/// The path.
/// Type of the model.
- public ContextPathMap(string path, Type modelType) : this()
+ public ContextPathMap(string path, Type modelType)
+ : this()
{
- Path = path;
- ModelType = modelType;
+ this.Path = path;
+ this.ModelType = modelType;
}
///
@@ -50,20 +51,20 @@ public ContextPathMap(string path, Type modelType) : this()
///
public bool Equals(ContextPathMap other)
{
- return string.Equals(Path, other.Path) && ModelType == other.ModelType;
+ return string.Equals(this.Path, other.Path) && this.ModelType == other.ModelType;
}
///
/// Checks equality
///
- public override bool Equals(object obj)
+ public override bool Equals([AllowNull] object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
- return obj is ContextPathMap && Equals((ContextPathMap)obj);
+ return obj is ContextPathMap && this.Equals((ContextPathMap)obj);
}
///
@@ -73,7 +74,7 @@ public override int GetHashCode()
{
unchecked
{
- return ((Path != null ? Path.GetHashCode() : 0) * 397) ^ (ModelType != null ? ModelType.GetHashCode() : 0);
+ return ((this.Path != null ? this.Path.GetHashCode() : 0) * 397) ^ (this.ModelType != null ? this.ModelType.GetHashCode() : 0);
}
}
}
diff --git a/src/Nancy.Rdf/Contexts/DefaultContextPathMapper.cs b/src/Nancy.Rdf/Contexts/DefaultContextPathMapper.cs
index 9acc5e3..e5cb3e9 100644
--- a/src/Nancy.Rdf/Contexts/DefaultContextPathMapper.cs
+++ b/src/Nancy.Rdf/Contexts/DefaultContextPathMapper.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace Nancy.Rdf.Contexts
{
@@ -8,14 +8,14 @@ namespace Nancy.Rdf.Contexts
public class DefaultContextPathMapper : IContextPathMapper
{
private const string DefaultContextPath = "_contexts";
- private readonly IList _contexts = new List();
+ private readonly IList contexts = new List();
///
/// Initializes a new instance of the class.
///
public DefaultContextPathMapper()
{
- BasePath = DefaultContextPath;
+ this.BasePath = DefaultContextPath;
}
///
@@ -28,7 +28,7 @@ public DefaultContextPathMapper()
///
public IEnumerable Contexts
{
- get { return _contexts; }
+ get { return this.contexts; }
}
///
@@ -37,7 +37,7 @@ public IEnumerable Contexts
/// model type
protected void ServeContextOf()
{
- ServeContextOf(typeof(T).Name);
+ this.ServeContextOf(typeof(T).Name);
}
///
@@ -47,7 +47,7 @@ protected void ServeContextOf()
/// The path to server the @context at.
protected void ServeContextOf(string path)
{
- _contexts.Add(new ContextPathMap(path, typeof(T)));
+ this.contexts.Add(new ContextPathMap(path, typeof(T)));
}
}
}
diff --git a/src/Nancy.Rdf/Contexts/IContextPathMapper.cs b/src/Nancy.Rdf/Contexts/IContextPathMapper.cs
index a761d34..53e374c 100644
--- a/src/Nancy.Rdf/Contexts/IContextPathMapper.cs
+++ b/src/Nancy.Rdf/Contexts/IContextPathMapper.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace Nancy.Rdf.Contexts
{
diff --git a/src/Nancy.Rdf/Contexts/JsonLdContextModule.cs b/src/Nancy.Rdf/Contexts/JsonLdContextModule.cs
index 225f895..49a1f97 100644
--- a/src/Nancy.Rdf/Contexts/JsonLdContextModule.cs
+++ b/src/Nancy.Rdf/Contexts/JsonLdContextModule.cs
@@ -10,7 +10,7 @@ namespace Nancy.Rdf.Contexts
///
public class JsonLdContextModule : NancyModule
{
- private readonly ContextResolver _resolver;
+ private readonly ContextResolver resolver;
///
/// Initializes a new instance of the class.
@@ -20,11 +20,11 @@ public class JsonLdContextModule : NancyModule
public JsonLdContextModule(IContextPathMapper pathProvider, IContextProvider provider)
: base(pathProvider.BasePath)
{
- _resolver = new ContextResolver(provider);
+ this.resolver = new ContextResolver(provider);
foreach (var path in pathProvider.Contexts)
{
- Get[path.Path] = ServeContextOf(path.ModelType);
+ this.Get(path.Path, this.ServeContextOf(path.ModelType));
}
}
@@ -41,10 +41,10 @@ public JsonLdContextModule()
{
var context = new JObject
{
- { JsonLdKeywords.Context, _resolver.GetContext(modelType) }
+ { JsonLdKeywords.Context, this.resolver.GetContext(modelType) }
};
var response = new TextResponse(context.ToString(), RdfSerialization.JsonLd.MediaType);
- return Negotiate.WithAllowedMediaRange(RdfSerialization.JsonLd.MediaType)
+ return this.Negotiate.WithAllowedMediaRange(RdfSerialization.JsonLd.MediaType)
.WithMediaRangeResponse(RdfSerialization.JsonLd.MediaType, response);
};
}
diff --git a/src/Nancy.Rdf/DictionaryNamespaceManager.cs b/src/Nancy.Rdf/DictionaryNamespaceManager.cs
index 9ea847d..308e6d4 100644
--- a/src/Nancy.Rdf/DictionaryNamespaceManager.cs
+++ b/src/Nancy.Rdf/DictionaryNamespaceManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -11,14 +11,14 @@ namespace Nancy.Rdf
///
internal class DictionaryNamespaceManager : INamespaceManager
{
- private readonly IDictionary _namespaces;
+ private readonly IDictionary namespaces;
///
/// Initializes a new instance of the class.
///
public DictionaryNamespaceManager()
{
- _namespaces = new Dictionary();
+ this.namespaces = new Dictionary();
}
///
@@ -27,25 +27,25 @@ public DictionaryNamespaceManager()
///
public IEnumerator GetEnumerator()
{
- return _namespaces.Select(p => new NamespaceMap(p.Key, p.Value)).GetEnumerator();
+ return this.namespaces.Select(p => new NamespaceMap(p.Key, p.Value)).GetEnumerator();
}
///
IEnumerator IEnumerable.GetEnumerator()
{
- return GetEnumerator();
+ return this.GetEnumerator();
}
///
public void AddNamespace(string prefix, Uri ns)
{
- _namespaces.Add(prefix, ns);
+ this.namespaces.Add(prefix, ns);
}
///
public void SetBaseUri([AllowNull] Uri baseUri)
{
- BaseUri = baseUri;
+ this.BaseUri = baseUri;
}
}
}
diff --git a/src/Nancy.Rdf/Installer.cs b/src/Nancy.Rdf/Installer.cs
index 31869e0..316b621 100644
--- a/src/Nancy.Rdf/Installer.cs
+++ b/src/Nancy.Rdf/Installer.cs
@@ -12,11 +12,12 @@ public class Installer : Registrations
///
/// Initializes a new instance of the class.
///
- public Installer()
+ public Installer(ITypeCatalog typeCatalog)
+ : base(typeCatalog)
{
- RegisterWithDefault(typeof(DictionaryNamespaceManager));
- RegisterWithDefault(typeof(DefaultContextPathMapper));
- Register(typeof(EntitySerializer));
+ this.RegisterWithDefault(typeof(DictionaryNamespaceManager));
+ this.RegisterWithDefault(typeof(DefaultContextPathMapper));
+ this.Register(typeof(EntitySerializer));
}
}
}
diff --git a/src/Nancy.Rdf/JsonLdProfiles.cs b/src/Nancy.Rdf/JsonLdProfiles.cs
index ee93961..d125592 100644
--- a/src/Nancy.Rdf/JsonLdProfiles.cs
+++ b/src/Nancy.Rdf/JsonLdProfiles.cs
@@ -1,4 +1,4 @@
-namespace Nancy.Rdf
+namespace Nancy.Rdf
{
///
/// Predefined JSON-LD ACCEPT header profiles
diff --git a/src/Nancy.Rdf/ModelBinding/IRdfConverter.cs b/src/Nancy.Rdf/ModelBinding/IRdfConverter.cs
new file mode 100644
index 0000000..6de4d53
--- /dev/null
+++ b/src/Nancy.Rdf/ModelBinding/IRdfConverter.cs
@@ -0,0 +1,17 @@
+using System.IO;
+using VDS.RDF;
+
+namespace Nancy.Rdf.ModelBinding
+{
+ ///
+ /// Converts RDF serializations to n-triples
+ ///
+ public interface IRdfConverter
+ {
+ ///
+ /// Converts to nquads.
+ ///
+ /// input rdf serialized as n-triples
+ string ConvertToNtriples(Stream rdf, IRdfReader reader);
+ }
+}
\ No newline at end of file
diff --git a/src/Nancy.Rdf/ModelBinding/JsonldBodyDeserializer.cs b/src/Nancy.Rdf/ModelBinding/JsonldBodyDeserializer.cs
new file mode 100644
index 0000000..184f640
--- /dev/null
+++ b/src/Nancy.Rdf/ModelBinding/JsonldBodyDeserializer.cs
@@ -0,0 +1,40 @@
+using System.IO;
+using System.Reflection;
+using JsonLD.Entities;
+using Nancy.ModelBinding;
+using Nancy.Responses.Negotiation;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace Nancy.Rdf.ModelBinding
+{
+ ///
+ /// Deserializes JSON-LD request body to model
+ ///
+ public class JsonldBodyDeserializer : RdfBodyDeserializer
+ {
+ private static readonly MethodInfo DeserializeJsonLdMethod = typeof(IEntitySerializer).GetMethod("Deserialize", new[] { typeof(JToken) });
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public JsonldBodyDeserializer(IEntitySerializer serializer)
+ : base(serializer, RdfSerialization.JsonLd)
+ {
+ }
+
+ ///
+ /// Deserialize the request body to a model
+ ///
+ public override object Deserialize(MediaRange contentType, Stream body, BindingContext context)
+ {
+ body.Position = 0;
+ using (var bodyReader = new StreamReader(body))
+ {
+ var deserialize = DeserializeJsonLdMethod.MakeGenericMethod(context.DestinationType);
+
+ return deserialize.Invoke(this.Serializer, new object[] { JToken.ReadFrom(new JsonTextReader(bodyReader)) });
+ }
+ }
+ }
+}
diff --git a/src/Nancy.Rdf/ModelBinding/NonJsonLdRdfBodyDeserializer.cs b/src/Nancy.Rdf/ModelBinding/NonJsonLdRdfBodyDeserializer.cs
new file mode 100644
index 0000000..41d59ee
--- /dev/null
+++ b/src/Nancy.Rdf/ModelBinding/NonJsonLdRdfBodyDeserializer.cs
@@ -0,0 +1,78 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using JsonLD.Entities;
+using Nancy.ModelBinding;
+using Nancy.Responses.Negotiation;
+using VDS.RDF;
+using VDS.RDF.Parsing;
+using VDS.RDF.Writing;
+
+namespace Nancy.Rdf.ModelBinding
+{
+ ///
+ /// Deserializers request body, first converting it to n-triples
+ ///
+ public class NonJsonLdRdfBodyDeserializer : RdfBodyDeserializer
+ {
+ private static readonly MethodInfo DeserializeNquadsMethod = typeof(IEntitySerializer).GetMethod("Deserialize", new[] { typeof(string) });
+
+ private readonly IDictionary readers;
+ private readonly IRdfConverter converter;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public NonJsonLdRdfBodyDeserializer(IEntitySerializer serializer)
+ : this(serializer, new RdfConverter())
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public NonJsonLdRdfBodyDeserializer(
+ IEntitySerializer serializer,
+ IRdfConverter converter)
+ : this(serializer, RdfSerialization.RdfXml, RdfSerialization.NTriples, RdfSerialization.Notation3, RdfSerialization.Turtle)
+ {
+ this.converter = converter;
+ }
+
+ private NonJsonLdRdfBodyDeserializer(IEntitySerializer serializer, params RdfSerialization[] serializations)
+ : base(serializer, serializations)
+ {
+ this.readers = new Dictionary
+ {
+ { RdfSerialization.Notation3, new Notation3Parser() },
+ { RdfSerialization.RdfXml, new RdfXmlParser() },
+ { RdfSerialization.Turtle, new TurtleParser() }
+ };
+ }
+
+ ///
+ /// Deserialize the request body to a model
+ ///
+ public override object Deserialize(MediaRange contentType, Stream body, BindingContext context)
+ {
+ var deserialize = DeserializeNquadsMethod.MakeGenericMethod(context.DestinationType);
+ string nquads;
+
+ if (contentType.Matches(RdfSerialization.NTriples.MediaType))
+ {
+ using (var bodyReader = new StreamReader(body))
+ {
+ nquads = bodyReader.ReadToEnd();
+ }
+ }
+ else
+ {
+ var reader = this.readers.First(r => contentType.Matches(r.Key.MediaType)).Value;
+ nquads = this.converter.ConvertToNtriples(body, reader);
+ }
+
+ return deserialize.Invoke(this.Serializer, new object[] { nquads });
+ }
+ }
+}
diff --git a/src/Nancy.Rdf/ModelBinding/RdfBodyDeserializer.cs b/src/Nancy.Rdf/ModelBinding/RdfBodyDeserializer.cs
new file mode 100644
index 0000000..8204e66
--- /dev/null
+++ b/src/Nancy.Rdf/ModelBinding/RdfBodyDeserializer.cs
@@ -0,0 +1,44 @@
+using System.IO;
+using System.Linq;
+using JsonLD.Entities;
+using Nancy.ModelBinding;
+using Nancy.Responses.Negotiation;
+
+namespace Nancy.Rdf.ModelBinding
+{
+ ///
+ /// Deserializes RDF bodies to POCO models
+ ///
+ public abstract class RdfBodyDeserializer : IBodyDeserializer
+ {
+ private readonly MediaRange[] serializations;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ protected RdfBodyDeserializer(IEntitySerializer serializer, params RdfSerialization[] serializations)
+ {
+ this.serializations = serializations.Select(s => new MediaRange(s.MediaType)).ToArray();
+ this.Serializer = serializer;
+ }
+
+ ///
+ /// Gets the serializer.
+ ///
+ protected IEntitySerializer Serializer { get; }
+
+ ///
+ /// Determines whether this instance can deserialize the specified content type.
+ ///
+ /// true for any of
+ public bool CanDeserialize(MediaRange contentType, BindingContext context)
+ {
+ return this.serializations.Any(contentType.Matches);
+ }
+
+ ///
+ /// Deserialize the request body to a model
+ ///
+ public abstract object Deserialize(MediaRange contentType, Stream body, BindingContext context);
+ }
+}
diff --git a/src/Nancy.Rdf/ModelBinding/RdfConverter.cs b/src/Nancy.Rdf/ModelBinding/RdfConverter.cs
new file mode 100644
index 0000000..754c6ae
--- /dev/null
+++ b/src/Nancy.Rdf/ModelBinding/RdfConverter.cs
@@ -0,0 +1,38 @@
+using System.IO;
+using VDS.RDF;
+using VDS.RDF.Parsing;
+using VDS.RDF.Writing;
+using StringWriter = System.IO.StringWriter;
+
+namespace Nancy.Rdf.ModelBinding
+{
+ ///
+ /// Converts RDF serializations to n-triples
+ ///
+ ///
+ public class RdfConverter : IRdfConverter
+ {
+ private static readonly NTriplesWriter NTriplesWriter = new NTriplesWriter(NTriplesSyntax.Rdf11);
+
+ ///
+ /// Converts to nquads.
+ ///
+ /// input rdf serialized as n-triples
+ public string ConvertToNtriples(Stream rdf, IRdfReader reader)
+ {
+ // todo: implement actual parsers for json-ld.net so that it's not necessary to parse and write to ntriples
+ IGraph g = new Graph();
+
+ using (var streamReader = new StreamReader(rdf))
+ {
+ reader.Load(g, streamReader);
+ }
+
+ using (var stringWriter = new StringWriter())
+ {
+ NTriplesWriter.Save(g, stringWriter);
+ return stringWriter.ToString();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Nancy.Rdf/NamespaceMap.cs b/src/Nancy.Rdf/NamespaceMap.cs
index d2eeaad..cc0ff6c 100644
--- a/src/Nancy.Rdf/NamespaceMap.cs
+++ b/src/Nancy.Rdf/NamespaceMap.cs
@@ -10,10 +10,11 @@ public struct NamespaceMap
///
/// Initializes a new instance of the struct.
///
- public NamespaceMap(string prefix, Uri ns) : this()
+ public NamespaceMap(string prefix, Uri ns)
+ : this()
{
- Namespace = ns;
- Prefix = prefix;
+ this.Namespace = ns;
+ this.Prefix = prefix;
}
///
diff --git a/src/Nancy.Rdf/Nancy.Rdf.csproj b/src/Nancy.Rdf/Nancy.Rdf.csproj
index c4e5b7e..8162734 100644
--- a/src/Nancy.Rdf/Nancy.Rdf.csproj
+++ b/src/Nancy.Rdf/Nancy.Rdf.csproj
@@ -1,5 +1,5 @@
-
+
Debug
@@ -12,8 +12,9 @@
Nancy.Rdf
Nancy.Rdf
.NETFramework
- v4.0
+ v4.5.2
512
+
true
@@ -24,7 +25,10 @@
prompt
4
bin\Debug\Nancy.Rdf.xml
- Nancy.Rdf.ruleset
+
+
+ false
+ true
pdbonly
@@ -35,7 +39,8 @@
4
bin\Release\Nancy.Rdf.xml
true
- Nancy.Rdf.ruleset
+ ..\..\paket-files\tpluscode\a285267d2543466fc35c3a168c846f9f\Library.ruleset
+ false
@@ -57,6 +62,11 @@
+
+
+
+
+
@@ -85,27 +95,26 @@
-
-
+
<__paket__GitVersionTask_targets>portable-net+sl+win+wpa+wp\GitVersionTask
-
+
<__paket__Fody_targets>portable-net+sl+win+wpa+wp\Fody
-
+
..\..\packages\dotNetRDF\lib\net40\dotNetRDF.dll
@@ -116,19 +125,21 @@
-
+
- ..\..\packages\HtmlAgilityPack\lib\Net40\HtmlAgilityPack.dll
+ ..\..\packages\HtmlAgilityPack\lib\Net45\HtmlAgilityPack.dll
True
True
-
+
+
+
-
- ..\..\packages\HtmlAgilityPack\lib\Net45\HtmlAgilityPack.dll
+
+ ..\..\packages\json-ld.net\lib\net40-client\json-ld.net.dll
True
True
@@ -136,10 +147,10 @@
-
+
- ..\..\packages\JsonLD.Entities\lib\net40\JsonLD.Entities.dll
+ ..\..\packages\JsonLd.Entities\lib\net40\JsonLD.Entities.dll
True
True
@@ -147,10 +158,10 @@
-
+
-
- ..\..\packages\json-ld.net\lib\net40-client\json-ld.net.dll
+
+ ..\..\packages\Microsoft.DotNet.PlatformAbstractions\lib\net451\Microsoft.DotNet.PlatformAbstractions.dll
True
True
@@ -158,10 +169,10 @@
-
+
-
- ..\..\packages\Nancy\lib\net40\Nancy.dll
+
+ ..\..\packages\Microsoft.Extensions.DependencyModel\lib\net451\Microsoft.Extensions.DependencyModel.dll
True
True
@@ -169,16 +180,18 @@
-
+
-
- ..\..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll
+
+ ..\..\packages\Nancy\lib\net452\Nancy.dll
True
True
-
+
+
+
..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll
@@ -189,7 +202,7 @@
-
+
..\..\packages\NullGuard.Fody\Lib\portable-net4+sl5+wpa81+wp8+win8+MonoAndroid16+MonoTouch40\NullGuard.dll
@@ -200,7 +213,7 @@
-
+
..\..\packages\Rdf.Vocabularies\lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\Rdf.Vocabularies.dll
@@ -224,7 +237,7 @@
-
+
..\..\packages\VDS.Common\lib\net40-client\VDS.Common.dll
diff --git a/src/Nancy.Rdf/Nancy.Rdf.ruleset b/src/Nancy.Rdf/Nancy.Rdf.ruleset
deleted file mode 100644
index 0baeacb..0000000
--- a/src/Nancy.Rdf/Nancy.Rdf.ruleset
+++ /dev/null
@@ -1,238 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Nancy.Rdf/RdfResponses.cs b/src/Nancy.Rdf/RdfResponses.cs
index 72e1efc..3b2bd7e 100644
--- a/src/Nancy.Rdf/RdfResponses.cs
+++ b/src/Nancy.Rdf/RdfResponses.cs
@@ -1,5 +1,4 @@
using Nancy.Bootstrapper;
-using Nancy.Rdf.Responses;
namespace Nancy.Rdf
{
@@ -8,6 +7,9 @@ namespace Nancy.Rdf
///
public static class RdfResponses
{
+ ///
+ /// The key used to store default RDF serialization in Nancy's context
+ ///
internal const string FallbackSerializationKey = "__nrfs";
///
diff --git a/src/Nancy.Rdf/RdfSerialization.cs b/src/Nancy.Rdf/RdfSerialization.cs
index a7e69ce..c053eee 100644
--- a/src/Nancy.Rdf/RdfSerialization.cs
+++ b/src/Nancy.Rdf/RdfSerialization.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using NullGuard;
namespace Nancy.Rdf
{
@@ -8,13 +9,13 @@ namespace Nancy.Rdf
///
public struct RdfSerialization
{
- private readonly string _mediaType;
- private readonly string _extension;
+ private readonly string mediaType;
+ private readonly string extension;
private RdfSerialization(string mediaType, string extension)
{
- _mediaType = mediaType;
- _extension = extension;
+ this.mediaType = mediaType;
+ this.extension = extension;
}
///
@@ -92,7 +93,7 @@ public static RdfSerialization NTriples
///
public string MediaType
{
- get { return _mediaType; }
+ get { return this.mediaType; }
}
///
@@ -100,7 +101,7 @@ public string MediaType
///
public string Extension
{
- get { return _extension; }
+ get { return this.extension; }
}
#pragma warning disable 1591
@@ -119,18 +120,18 @@ public string Extension
[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Operator or built-in override")]
public bool Equals(RdfSerialization other)
{
- return string.Equals(_mediaType, other._mediaType) && string.Equals(_extension, other._extension);
+ return string.Equals(this.mediaType, other.mediaType) && string.Equals(this.extension, other.extension);
}
[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Operator or built-in override")]
- public override bool Equals(object obj)
+ public override bool Equals([AllowNull] object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
- return obj is RdfSerialization && Equals((RdfSerialization)obj);
+ return obj is RdfSerialization && this.Equals((RdfSerialization)obj);
}
[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Operator or built-in override")]
@@ -138,7 +139,7 @@ public override int GetHashCode()
{
unchecked
{
- return (_mediaType.GetHashCode() * 397) ^ _extension.GetHashCode();
+ return (this.mediaType.GetHashCode() * 397) ^ this.extension.GetHashCode();
}
}
#pragma warning restore
@@ -148,7 +149,7 @@ public override int GetHashCode()
///
public override string ToString()
{
- return MediaType;
+ return this.MediaType;
}
}
}
diff --git a/src/Nancy.Rdf/Responses/CompressingSerializer.cs b/src/Nancy.Rdf/Responses/CompressingSerializer.cs
index b3fbe44..8bdaef4 100644
--- a/src/Nancy.Rdf/Responses/CompressingSerializer.cs
+++ b/src/Nancy.Rdf/Responses/CompressingSerializer.cs
@@ -10,7 +10,7 @@ namespace Nancy.Rdf.Responses
///
public abstract class CompressingSerializer : RdfSerializer
{
- private readonly INamespaceManager _namespaces;
+ private readonly INamespaceManager namespaces;
///
/// Initializes a new instance of the class.
@@ -21,7 +21,7 @@ public abstract class CompressingSerializer : RdfSerializer
protected CompressingSerializer(RdfSerialization rdfSerialization, IEntitySerializer entitySerializer, INamespaceManager namespaces)
: base(rdfSerialization, entitySerializer)
{
- _namespaces = namespaces;
+ this.namespaces = namespaces;
}
///
@@ -29,14 +29,14 @@ protected CompressingSerializer(RdfSerialization rdfSerialization, IEntitySerial
///
protected override void WriteRdf(StreamWriter writer, IEnumerable triples)
{
- var graph = new Graph(true) { BaseUri = _namespaces.BaseUri };
- foreach (var ns in _namespaces)
+ var graph = new Graph(true) { BaseUri = this.namespaces.BaseUri };
+ foreach (var ns in this.namespaces)
{
graph.NamespaceMap.AddNamespace(ns.Prefix, ns.Namespace);
}
graph.Assert(triples);
- graph.SaveToStream(writer, CreateWriter());
+ graph.SaveToStream(writer, this.CreateWriter());
}
///
diff --git a/src/Nancy.Rdf/Responses/JsonLdSerializer.cs b/src/Nancy.Rdf/Responses/JsonLdSerializer.cs
index eaf59a1..63ddd4c 100644
--- a/src/Nancy.Rdf/Responses/JsonLdSerializer.cs
+++ b/src/Nancy.Rdf/Responses/JsonLdSerializer.cs
@@ -18,16 +18,16 @@ namespace Nancy.Rdf.Responses
public class JsonLdSerializer : IRdfSerializer
{
private static readonly RdfSerialization JsonLdSerialization = RdfSerialization.JsonLd;
- private readonly IEntitySerializer _serializer;
- private readonly IContextPathMapper _contextPathMapper;
+ private readonly IEntitySerializer serializer;
+ private readonly IContextPathMapper contextPathMapper;
///
/// Initializes a new instance of the class.
///
public JsonLdSerializer(IEntitySerializer serializer, IContextPathMapper contextPathMapper)
{
- _serializer = serializer;
- _contextPathMapper = contextPathMapper;
+ this.serializer = serializer;
+ this.contextPathMapper = contextPathMapper;
}
///
@@ -44,39 +44,37 @@ public IEnumerable Extensions
///
/// Whether the serializer can serialize the content type
///
- /// Content type to serialize
+ /// Content type to serialize
///
/// True if supported, false otherwise
///
- public bool CanSerialize(string contentType)
+ public bool CanSerialize(MediaRange mediaRange)
{
- return JsonLdSerialization.MediaType.Equals(contentType, StringComparison.InvariantCultureIgnoreCase);
+ return JsonLdSerialization.MediaType.Equals(mediaRange, StringComparison.InvariantCultureIgnoreCase);
}
///
/// Serializes the specified content type.
///
/// The type of the model.
- /// Type of the content.
+ /// Type of the content.
/// The model.
/// The output stream.
- public void Serialize(string contentType, TModel model, Stream outputStream)
+ public void Serialize(MediaRange mediaRange, TModel model, Stream outputStream)
{
WrappedModel? wrappedModel = model as WrappedModel?;
var actualModel = wrappedModel == null ? model : wrappedModel.Value.Model;
using (var writer = new StreamWriter(new UnclosableStreamWrapper(outputStream)))
{
- JToken serialized = _serializer.Serialize(actualModel);
+ JToken serialized = this.serializer.Serialize(actualModel);
if (wrappedModel.HasValue)
{
serialized.AddBaseToContext(wrappedModel.Value.BaseUrl);
}
- var mediaRange = new MediaRange(contentType);
-
- if (mediaRange.Parameters["profile"] == JsonLdProfiles.Expanded)
+ if (mediaRange.Parameters["profile"]?.Trim('"') == JsonLdProfiles.Expanded)
{
serialized = JsonLdProcessor.Expand(serialized);
}
@@ -84,12 +82,12 @@ public void Serialize(string contentType, TModel model, Stream outputStr
{
if (serialized[JsonLdKeywords.Context] != null)
{
- var contextMap = _contextPathMapper.Contexts.FirstOrDefault(map => map.ModelType == actualModel.GetType());
+ var contextMap = this.contextPathMapper.Contexts.FirstOrDefault(map => map.ModelType == actualModel.GetType());
if (contextMap != default(ContextPathMap) && wrappedModel != null)
{
var newContext = wrappedModel.Value.BaseUrl
- .Append(_contextPathMapper.BasePath)
+ .Append(this.contextPathMapper.BasePath)
.Append(contextMap.Path);
serialized[JsonLdKeywords.Context] = newContext;
}
diff --git a/src/Nancy.Rdf/Responses/RdfResponseProcessor.cs b/src/Nancy.Rdf/Responses/RdfResponseProcessor.cs
index bc3dcf9..5dc19a7 100644
--- a/src/Nancy.Rdf/Responses/RdfResponseProcessor.cs
+++ b/src/Nancy.Rdf/Responses/RdfResponseProcessor.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Nancy.Responses.Negotiation;
+using NullGuard;
namespace Nancy.Rdf.Responses
{
@@ -10,8 +11,8 @@ namespace Nancy.Rdf.Responses
///
public abstract class RdfResponseProcessor : IResponseProcessor
{
- private readonly RdfSerialization _serialization;
- private readonly ISerializer _serializer;
+ private readonly RdfSerialization serialization;
+ private readonly ISerializer serializer;
///
/// Initializes a new instance of the class.
@@ -20,8 +21,8 @@ public abstract class RdfResponseProcessor : IResponseProcessor
/// The serializers.
protected RdfResponseProcessor(RdfSerialization serialization, IEnumerable serializers)
{
- _serialization = serialization;
- _serializer = serializers.Cast().FirstOrDefault(s => s.CanSerialize(serialization.MediaType));
+ this.serialization = serialization;
+ this.serializer = serializers.Cast().FirstOrDefault(s => s.CanSerialize(serialization.MediaType));
}
///
@@ -31,29 +32,29 @@ protected RdfResponseProcessor(RdfSerialization serialization, IEnumerable
/// Determines whether the given and be processed in
///
- public ProcessorMatch CanProcess(MediaRange requestedMediaRange, dynamic model, NancyContext context)
+ public ProcessorMatch CanProcess(MediaRange requestedMediaRange, [AllowNull] dynamic model, NancyContext context)
{
var match = new ProcessorMatch
{
- ModelResult = MatchResult.DontCare
+ ModelResult = model == null ? MatchResult.NoMatch : MatchResult.DontCare
};
- if (_serializer != null)
+ if (this.serializer != null)
{
- if (new MediaRange(_serialization.MediaType).Matches(requestedMediaRange))
+ if (new MediaRange(this.serialization.MediaType).Matches(requestedMediaRange))
{
if (requestedMediaRange.IsWildcard == false)
{
match.RequestedContentTypeResult = MatchResult.ExactMatch;
}
- else if (GetFallbackSerialization(context) == _serialization)
+ else if (GetFallbackSerialization(context) == this.serialization)
{
match.RequestedContentTypeResult = MatchResult.NonExactMatch;
}
@@ -74,10 +75,10 @@ public Response Process(MediaRange requestedMediaRange, dynamic model, NancyCont
Contents = stream =>
{
var wrappedModel = new WrappedModel(model, context.Request.Url.SiteBase);
- _serializer.Serialize(requestedMediaRange, wrappedModel, stream);
+ this.serializer.Serialize(requestedMediaRange, wrappedModel, stream);
},
StatusCode = HttpStatusCode.OK,
- ContentType = _serialization.MediaType
+ ContentType = this.serialization.MediaType
};
}
diff --git a/src/Nancy.Rdf/Responses/RdfSerializer.cs b/src/Nancy.Rdf/Responses/RdfSerializer.cs
index 5c1a30f..5cb1313 100644
--- a/src/Nancy.Rdf/Responses/RdfSerializer.cs
+++ b/src/Nancy.Rdf/Responses/RdfSerializer.cs
@@ -6,6 +6,7 @@
using JsonLD.Core;
using JsonLD.Entities;
using Nancy.IO;
+using Nancy.Responses.Negotiation;
using VDS.RDF;
namespace Nancy.Rdf.Responses
@@ -15,9 +16,9 @@ namespace Nancy.Rdf.Responses
///
public abstract class RdfSerializer : IRdfSerializer
{
- private readonly RdfSerialization _serialization;
- private readonly INodeFactory _nodeFactory;
- private readonly IEntitySerializer _entitySerializer;
+ private readonly RdfSerialization serialization;
+ private readonly INodeFactory nodeFactory;
+ private readonly IEntitySerializer entitySerializer;
///
/// Initializes a new instance of the class.
@@ -26,33 +27,33 @@ public abstract class RdfSerializer : IRdfSerializer
/// The entity serializer.
protected RdfSerializer(RdfSerialization serialization, IEntitySerializer entitySerializer)
{
- _serialization = serialization;
- _entitySerializer = entitySerializer;
+ this.serialization = serialization;
+ this.entitySerializer = entitySerializer;
- _nodeFactory = new NodeFactory();
+ this.nodeFactory = new NodeFactory();
}
///
public IEnumerable Extensions
{
- get { yield return _serialization.Extension; }
+ get { yield return this.serialization.Extension; }
}
///
- public virtual bool CanSerialize(string contentType)
+ public virtual bool CanSerialize(MediaRange contentType)
{
- return _serialization.MediaType.Equals(contentType, StringComparison.InvariantCultureIgnoreCase);
+ return this.serialization.MediaType.Equals(contentType, StringComparison.InvariantCultureIgnoreCase);
}
///
- public void Serialize(string contentType, TModel model, Stream outputStream)
+ public void Serialize(MediaRange contentType, TModel model, Stream outputStream)
{
WrappedModel? wrappedModel = model as WrappedModel?;
var actualModel = wrappedModel == null ? model : wrappedModel.Value.Model;
using (var writer = new StreamWriter(new UnclosableStreamWrapper(outputStream)))
{
- var javascriptObject = _entitySerializer.Serialize(actualModel);
+ var javascriptObject = this.entitySerializer.Serialize(actualModel);
if (wrappedModel != null)
{
javascriptObject.AddBaseToContext(wrappedModel.Value.BaseUrl);
@@ -60,7 +61,7 @@ public void Serialize(string contentType, TModel model, Stream outputStr
var rdf = (RDFDataset)JsonLdProcessor.ToRDF(javascriptObject);
- WriteRdf(writer, rdf.GetQuads("@default").Select(ToTriple));
+ this.WriteRdf(writer, rdf.GetQuads("@default").Select(this.ToTriple));
}
}
@@ -73,25 +74,25 @@ private INode CreateNode(RDFDataset.Node node)
{
if (node.IsIRI())
{
- return _nodeFactory.CreateUriNode(new Uri(node.GetValue()));
+ return this.nodeFactory.CreateUriNode(new Uri(node.GetValue()));
}
if (node.IsBlankNode())
{
- return _nodeFactory.CreateBlankNode(node.GetValue());
+ return this.nodeFactory.CreateBlankNode(node.GetValue());
}
var literal = node.GetValue();
var datatype = new Uri(node.GetDatatype());
- return _nodeFactory.CreateLiteralNode(literal, datatype);
+ return this.nodeFactory.CreateLiteralNode(literal, datatype);
}
private Triple ToTriple(RDFDataset.Quad triple)
{
- var subj = CreateNode(triple.GetSubject());
- var pred = CreateNode(triple.GetPredicate());
- var obj = CreateNode(triple.GetObject());
+ var subj = this.CreateNode(triple.GetSubject());
+ var pred = this.CreateNode(triple.GetPredicate());
+ var obj = this.CreateNode(triple.GetObject());
return new Triple(subj, pred, obj);
}
diff --git a/src/Nancy.Rdf/Responses/WrappedModel.cs b/src/Nancy.Rdf/Responses/WrappedModel.cs
index 5054ba4..d396b0e 100644
--- a/src/Nancy.Rdf/Responses/WrappedModel.cs
+++ b/src/Nancy.Rdf/Responses/WrappedModel.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Nancy.Rdf.Responses
{
@@ -12,8 +12,8 @@ public struct WrappedModel
///
public WrappedModel(object model, string siteBase)
{
- Model = model;
- BaseUrl = new Uri(siteBase, UriKind.Absolute);
+ this.Model = model;
+ this.BaseUrl = new Uri(siteBase, UriKind.Absolute);
}
///
diff --git a/src/Nancy.Rdf/UriExtensions.cs b/src/Nancy.Rdf/UriExtensions.cs
index 0eec8b2..929450a 100644
--- a/src/Nancy.Rdf/UriExtensions.cs
+++ b/src/Nancy.Rdf/UriExtensions.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Nancy.Rdf
{
diff --git a/src/Nancy.Rdf/app.config b/src/Nancy.Rdf/app.config
index 326e7f9..0d67cc4 100644
--- a/src/Nancy.Rdf/app.config
+++ b/src/Nancy.Rdf/app.config
@@ -1,9 +1,14 @@
-
+
+
+ True
+
+
+
True
-
+
diff --git a/src/Nancy.Rdf/paket.template b/src/Nancy.Rdf/paket.template
index 185668a..5e1334c 100644
--- a/src/Nancy.Rdf/paket.template
+++ b/src/Nancy.Rdf/paket.template
@@ -4,6 +4,7 @@ excludeddependencies
GitVersionTask
dependencies
JsonLD.Entities >= LOCKEDVERSION
+ Nancy >= LOCKEDVERSION
projectUrl
http://github.org/wikibus/Nancy.RDF
description