Skip to content

Commit 4e79a50

Browse files
committed
Using primary constructors
1 parent 4476552 commit 4e79a50

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

src/Rqlite.Internal/Request/JsonContent.cs

+9-12
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,19 @@ namespace Rqlite.Internal.Request;
1010
/// <summary>
1111
/// Serialises and encodes JSON content correctly for use in HttpRequestMessage.
1212
/// </summary>
13-
public sealed class JsonContent : StringContent
13+
/// <remarks>
14+
/// Serialise content and set encoding.
15+
/// </remarks>
16+
/// <param name="content">Content to be serialised as JSON.</param>
17+
public sealed class JsonContent(object? content) : StringContent(
18+
content: JsonSerializer.Serialize(content, SerialiserOptions),
19+
encoding: Encoding.UTF8,
20+
mediaType: "application/json"
21+
)
1422
{
1523
/// <summary>
1624
/// Shared options for JSON serialisation.
1725
/// </summary>
1826
public static JsonSerializerOptions SerialiserOptions { get; } =
1927
new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
20-
21-
/// <summary>
22-
/// Serialise content and set encoding.
23-
/// </summary>
24-
/// <param name="content">Content to be serialised as JSON.</param>
25-
public JsonContent(object? content) : base(
26-
content: JsonSerializer.Serialize(content, SerialiserOptions),
27-
encoding: Encoding.UTF8,
28-
mediaType: "application/json"
29-
)
30-
{ }
3128
}

src/Rqlite.Internal/Request/UriBuilder.cs

+6-9
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@
88
namespace Rqlite.Internal.Request;
99

1010
/// <inheritdoc cref="IUriBuilder"/>
11-
public sealed class UriBuilder : IUriBuilder
11+
/// <summary>
12+
/// Create builder with a URI path.
13+
/// </summary>
14+
/// <param name="path">URI path.</param>
15+
public sealed class UriBuilder(string path) : IUriBuilder
1216
{
1317
/// <inheritdoc/>
14-
public string Path { get; }
18+
public string Path { get; } = path.TrimStart('/');
1519

1620
/// <inheritdoc/>
1721
public NameValueCollection QueryVars { get; } = [];
1822

19-
/// <summary>
20-
/// Create builder with a URI path.
21-
/// </summary>
22-
/// <param name="path">URI path.</param>
23-
public UriBuilder(string path) =>
24-
Path = path.TrimStart('/');
25-
2623
/// <summary>
2724
/// Create builder and optionally include timings with all requests.
2825
/// </summary>

0 commit comments

Comments
 (0)