Skip to content

Commit b94741a

Browse files
committed
Formatting.
1 parent dd1e9b0 commit b94741a

2 files changed

Lines changed: 37 additions & 36 deletions

File tree

src/Gotenberg.Sharp.Api.Client/Extensions/TypedClientServiceCollectionExtensions.cs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,71 +18,73 @@
1818
using Gotenberg.Sharp.API.Client.Domain.Settings;
1919
using Gotenberg.Sharp.API.Client.Infrastructure.Pipeline;
2020

21-
22-
2321
using Microsoft.Extensions.DependencyInjection;
2422
using Microsoft.Extensions.Options;
2523

2624
namespace Gotenberg.Sharp.API.Client.Extensions;
2725

2826
/// <summary>
29-
/// Extension methods for registering GotenbergSharpClient with dependency injection.
27+
/// Extension methods for registering GotenbergSharpClient with dependency injection.
3028
/// </summary>
3129
public static class TypedClientServiceCollectionExtensions
3230
{
3331
/// <summary>
34-
/// Registers GotenbergSharpClient with dependency injection using configured options.
35-
/// Configure options via appsettings.json or by calling services.Configure&lt;GotenbergSharpClientOptions&gt;().
32+
/// Registers GotenbergSharpClient with dependency injection using configured options.
33+
/// Configure options via appsettings.json or by calling services.Configure&lt;GotenbergSharpClientOptions&gt;().
3634
/// </summary>
3735
/// <param name="services">The service collection.</param>
3836
/// <returns>An IHttpClientBuilder for further configuration.</returns>
3937
/// <exception cref="ArgumentNullException">Thrown when services is null.</exception>
4038
/// <remarks>
41-
/// This method configures the HttpClient with automatic compression, retry policies, and basic authentication if credentials are provided.
42-
/// Options should be configured in the "GotenbergSharpClient" section of appsettings.json or programmatically.
39+
/// This method configures the HttpClient with automatic compression, retry policies, and basic authentication if
40+
/// credentials are provided.
41+
/// Options should be configured in the "GotenbergSharpClient" section of appsettings.json or programmatically.
4342
/// </remarks>
4443
public static IHttpClientBuilder AddGotenbergSharpClient(
4544
this IServiceCollection services)
4645
{
47-
if (services == null) throw new ArgumentNullException(nameof(services));
48-
49-
return services.AddGotenbergSharpClient(
50-
(sp, client) =>
51-
{
52-
var ops = GetOptions(sp);
53-
client.Timeout = ops.TimeOut;
54-
client.BaseAddress = ops.ServiceUrl;
55-
});
46+
if (services == null)
47+
{
48+
throw new ArgumentNullException(nameof(services));
49+
}
50+
51+
return services.AddGotenbergSharpClient((sp, client) =>
52+
{
53+
var ops = GetOptions(sp);
54+
client.Timeout = ops.TimeOut;
55+
client.BaseAddress = ops.ServiceUrl;
56+
});
5657
}
5758

58-
5959
/// <summary>
60-
/// Registers GotenbergSharpClient with dependency injection using a custom HttpClient configuration.
60+
/// Registers GotenbergSharpClient with dependency injection using a custom HttpClient configuration.
6161
/// </summary>
6262
/// <param name="services">The service collection.</param>
6363
/// <param name="configureClient">Action to configure the HttpClient instance.</param>
6464
/// <returns>An IHttpClientBuilder for further configuration.</returns>
6565
/// <exception cref="ArgumentNullException">Thrown when configureClient is null.</exception>
6666
/// <remarks>
67-
/// This overload allows full control over HttpClient configuration. The client is configured with
68-
/// automatic compression, timeout handling, and exponential backoff retry policies.
67+
/// This overload allows full control over HttpClient configuration. The client is configured with
68+
/// automatic compression, timeout handling, and exponential backoff retry policies.
6969
/// </remarks>
7070
public static IHttpClientBuilder AddGotenbergSharpClient(
7171
this IServiceCollection services,
7272
Action<IServiceProvider, HttpClient> configureClient)
7373
{
74-
if (configureClient == null) throw new ArgumentNullException(nameof(configureClient));
74+
if (configureClient == null)
75+
{
76+
throw new ArgumentNullException(nameof(configureClient));
77+
}
7578

7679
var builder = services
7780
.AddHttpClient(nameof(GotenbergSharpClient), configureClient)
7881
.AddTypedClient<GotenbergSharpClient>()
79-
.ConfigurePrimaryHttpMessageHandler(
80-
() => new TimeoutHandler(
81-
new HttpClientHandler
82-
{
83-
AutomaticDecompression = DecompressionMethods.GZip
84-
| DecompressionMethods.Deflate
85-
}))
82+
.ConfigurePrimaryHttpMessageHandler(() => new TimeoutHandler(
83+
new HttpClientHandler
84+
{
85+
AutomaticDecompression = DecompressionMethods.GZip
86+
| DecompressionMethods.Deflate
87+
}))
8688
.AddHttpMessageHandler(sp =>
8789
{
8890
var ops = GetOptions(sp);

src/Gotenberg.Sharp.Api.Client/Infrastructure/Pipeline/TimeoutHandler.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
// limitations under the License.
1515

1616
using System.Diagnostics.CodeAnalysis;
17-
using System.Threading;
18-
19-
2017

2118
namespace Gotenberg.Sharp.API.Client.Infrastructure.Pipeline;
2219

23-
2420
[SuppressMessage("ReSharper", "CA2000")]
2521
// ReSharper disable once HollowTypeName
2622
public sealed class TimeoutHandler : DelegatingHandler
@@ -40,7 +36,7 @@ public TimeoutHandler(HttpMessageHandler? innerHandler = null)
4036
/// <value>
4137
/// The default timeout.
4238
/// </value>
43-
39+
4440
public TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromSeconds(300);
4541

4642
/// <summary>
@@ -54,7 +50,7 @@ protected override async Task<HttpResponseMessage> SendAsync(
5450
HttpRequestMessage request,
5551
CancellationToken cancellationToken)
5652
{
57-
using var cts = this.GetCancelTokenSource(request, cancellationToken);
53+
using var cts = GetCancelTokenSource(request, cancellationToken);
5854

5955
try
6056
{
@@ -71,8 +67,11 @@ protected override async Task<HttpResponseMessage> SendAsync(
7167
HttpRequestMessage request,
7268
CancellationToken cancelToken)
7369
{
74-
var timeout = request.GetTimeout() ?? this.DefaultTimeout;
75-
if (timeout == Timeout.InfiniteTimeSpan) return null;
70+
var timeout = request.GetTimeout() ?? DefaultTimeout;
71+
if (timeout == Timeout.InfiniteTimeSpan)
72+
{
73+
return null;
74+
}
7675

7776
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancelToken);
7877
cts.CancelAfter(timeout);

0 commit comments

Comments
 (0)