Skip to content

Commit 358340a

Browse files
committed
Enhance resource cleanup by marking FacturapiClient as sealed and implementing disposal pattern
1 parent 0d92666 commit 358340a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

FacturapiClient.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Facturapi
88
{
9-
public class FacturapiClient : IFacturapiClient
9+
public sealed class FacturapiClient : IFacturapiClient
1010
{
1111
public CustomerWrapper Customer { get; private set; }
1212
public ProductWrapper Product { get; private set; }
@@ -19,6 +19,7 @@ public class FacturapiClient : IFacturapiClient
1919
public ToolWrapper Tool { get; private set; }
2020
public WebhookWrapper Webhook { get; private set; }
2121
private readonly HttpClient httpClient;
22+
private bool disposed;
2223

2324
public FacturapiClient(string apiKey, string apiVersion = "v2")
2425
{
@@ -43,7 +44,14 @@ public FacturapiClient(string apiKey, string apiVersion = "v2")
4344

4445
public void Dispose()
4546
{
47+
if (this.disposed)
48+
{
49+
return;
50+
}
51+
4652
this.httpClient?.Dispose();
53+
this.disposed = true;
54+
GC.SuppressFinalize(this);
4755
}
4856
}
4957
}

0 commit comments

Comments
 (0)