-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1170 from json-api-dotnet/json-sourcegen
Minor serialization tweaks
- Loading branch information
Showing
24 changed files
with
254 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using JsonApiDotNetCore.Configuration; | ||
using JsonApiDotNetCore.Resources; | ||
using JsonApiDotNetCore.Resources.Annotations; | ||
using JsonApiDotNetCore.Serialization.Objects; | ||
using JsonApiDotNetCore.Serialization.Response; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Benchmarks.Tools; | ||
|
||
/// <summary> | ||
/// Renders hard-coded fake links, without depending on <see cref="HttpContext" />. | ||
/// </summary> | ||
internal sealed class FakeLinkBuilder : ILinkBuilder | ||
{ | ||
public TopLevelLinks GetTopLevelLinks() | ||
{ | ||
return new TopLevelLinks | ||
{ | ||
Self = "TopLevel:Self" | ||
}; | ||
} | ||
|
||
public ResourceLinks GetResourceLinks(ResourceType resourceType, IIdentifiable resource) | ||
{ | ||
return new ResourceLinks | ||
{ | ||
Self = "Resource:Self" | ||
}; | ||
} | ||
|
||
public RelationshipLinks GetRelationshipLinks(RelationshipAttribute relationship, IIdentifiable leftResource) | ||
{ | ||
return new RelationshipLinks | ||
{ | ||
Self = "Relationship:Self", | ||
Related = "Relationship:Related" | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using JsonApiDotNetCore.QueryStrings; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.WebUtilities; | ||
|
||
namespace Benchmarks.Tools; | ||
|
||
/// <summary> | ||
/// Enables to inject a query string, instead of obtaining it from <see cref="HttpContext" />. | ||
/// </summary> | ||
internal sealed class FakeRequestQueryStringAccessor : IRequestQueryStringAccessor | ||
{ | ||
public IQueryCollection Query { get; private set; } = new QueryCollection(); | ||
|
||
public void SetQueryString(string queryString) | ||
{ | ||
Query = new QueryCollection(QueryHelpers.ParseQuery(queryString)); | ||
} | ||
} |
Oops, something went wrong.