Skip to content

Commit 65d110d

Browse files
committed
[up] to Simplify.Web v5
[edit] according to Simplify.Web v5 [r] primary constructors, comments [del] .NET 4.8 explicit support
1 parent 9ae3563 commit 65d110d

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"cSpell.words": [
33
"cref",
44
"deserialized",
5+
"Newtonsoft",
56
"registrator"
67
]
78
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Nuget Download](https://img.shields.io/nuget/dt/Simplify.Web.Json)](https://www.nuget.org/packages/Simplify.Web.Json/)
55
[![Build Package](https://github.com/SimplifyNet/Simplify.Web.Json/actions/workflows/build.yml/badge.svg)](https://github.com/SimplifyNet/Simplify.Web.Json/actions/workflows/build.yml)[![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/nuget/Simplify.Web.Json)](https://libraries.io/nuget/Simplify.Web.Json)
66
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/SimplifyNet/Simplify.Web.Json)](https://www.codefactor.io/repository/github/simplifynet/simplify.web.Json)
7-
![Platform](https://img.shields.io/badge/platform-.NET%206.0%20%7C%20.NET%205.0%20%7C%20.NET%20Standard%202.0%20%7C%20.NET%204.6.2%20%7C%20.NET%20Core%203.1-lightgrey)
7+
![Platform](https://img.shields.io/badge/platform-.NET%206.0%20%7C%20.NET%20Standard%202.1%20%7C%20.NET%20Standard%202.0-lightgrey)
88
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](http://makeapullrequest.com)
99

1010
[Simplify.Web.Json](https://www.nuget.org/packages/Simplify.Web.Json/) is a package which provides JSON serialization/deserialization for [Simplify.Web](https://github.com/SimplifyNet/Simplify.Web) web-framework controllers.

src/Simplify.Web.Json/Responses/Json.cs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,34 @@ namespace Simplify.Web.Json.Responses;
66
/// <summary>
77
/// Provides controller JSON response (send only JSON string to response)
88
/// </summary>
9-
public class Json : ControllerResponse
9+
/// <seealso cref="ControllerResponse" />
10+
/// <remarks>
11+
/// Initializes a new instance of the <see cref="Json"/> class.
12+
/// </remarks>
13+
/// <param name="objectToConvert">The object to convert to JSON.</param>
14+
/// <param name="statusCode">The HTTP response status code.</param>
15+
public class Json(object objectToConvert, int statusCode = 200) : ControllerResponse
1016
{
11-
private readonly object _objectToConvert;
17+
private readonly object _objectToConvert = objectToConvert;
1218

1319
/// <summary>
1420
/// Gets the HTTP response status code.
1521
/// </summary>
1622
/// <value>
1723
/// The HTTP response status code.
1824
/// </value>
19-
private readonly int _statusCode;
25+
private readonly int _statusCode = statusCode;
2026

2127
/// <summary>
22-
/// Initializes a new instance of the <see cref="Json"/> class.
28+
/// Executes this response asynchronously.
2329
/// </summary>
24-
/// <param name="objectToConvert">The object to convert to JSON.</param>
25-
/// <param name="statusCode">The HTTP response status code.</param>
26-
public Json(object objectToConvert, int statusCode = 200)
27-
{
28-
_objectToConvert = objectToConvert;
29-
_statusCode = statusCode;
30-
}
31-
32-
/// <summary>
33-
/// Processes this response
34-
/// </summary>
35-
/// <returns></returns>
36-
public override async Task<ControllerResponseResult> Process()
30+
public override async Task<ResponseBehavior> ExecuteAsync()
3731
{
3832
Context.Response.ContentType = "application/json";
3933
Context.Response.StatusCode = _statusCode;
4034

41-
await ResponseWriter.WriteAsync(JsonConvert.SerializeObject(_objectToConvert), Context.Response);
35+
await ResponseWriter.WriteAsync(Context.Response, JsonConvert.SerializeObject(_objectToConvert));
4236

43-
return ControllerResponseResult.RawOutput;
37+
return ResponseBehavior.RawOutput;
4438
}
4539
}

src/Simplify.Web.Json/Simplify.Web.Json.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;netstandard2.1;netstandard2.0;net48</TargetFrameworks>
3+
<TargetFrameworks>net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
44
<LangVersion>latest</LangVersion>
55
<Nullable>enable</Nullable>
66
<CheckEolTargetFramework>false</CheckEolTargetFramework>
@@ -10,7 +10,7 @@
1010
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212

13-
<Version>2.3.1</Version>
13+
<Version>2.4-pre01</Version>
1414

1515
<Authors>Alexander Krylkov</Authors>
1616
<Product>Simplify</Product>
@@ -24,7 +24,7 @@
2424
<PackageReleaseNotes>See https://github.com/SimplifyNet/Simplify.Web.Json/tree/master/src/Simplify.Web.Json/CHANGELOG.md for details</PackageReleaseNotes>
2525
</PropertyGroup>
2626
<ItemGroup>
27-
<PackageReference Include="Simplify.Web" Version="4.8.1" />
27+
<PackageReference Include="Simplify.Web" Version="5.0-pre01" />
2828
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2929
</ItemGroup>
3030
<ItemGroup>

src/TesterApp/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
app.UseDeveloperExceptionPage();
1919

2020
// Enabling Simplify.Web JSON requests handling
21+
22+
HttpModelHandler.ModelBindersTypes.Clear();
2123
HttpModelHandler.RegisterModelBinder<JsonModelBinder>();
2224

23-
app.UseSimplifyWebWithoutRegistrations();
25+
app.UseSimplifyWeb();
2426

25-
app.Run();
27+
await app.RunAsync();

0 commit comments

Comments
 (0)