Dispose IDisposable instances (#15810)

This commit is contained in:
Chad
2024-03-14 03:59:28 +13:00
committed by GitHub
parent ac5539a8be
commit 2fbda6e64b
7 changed files with 16 additions and 10 deletions

View File

@@ -20,7 +20,7 @@ public class InstallationRepository : IInstallationRepository
_httpClient = new HttpClient();
}
var content = new StringContent(_jsonSerializer.Serialize(installLog), Encoding.UTF8, "application/json");
using var content = new StringContent(_jsonSerializer.Serialize(installLog), Encoding.UTF8, "application/json");
await _httpClient.PostAsync(RestApiInstallUrl, content);
}

View File

@@ -21,10 +21,10 @@ public class UpgradeCheckRepository : IUpgradeCheckRepository
_httpClient = new HttpClient();
}
var content = new StringContent(_jsonSerializer.Serialize(new CheckUpgradeDto(version)), Encoding.UTF8, "application/json");
using var content = new StringContent(_jsonSerializer.Serialize(new CheckUpgradeDto(version)), Encoding.UTF8, "application/json");
_httpClient.Timeout = TimeSpan.FromSeconds(1);
HttpResponseMessage task = await _httpClient.PostAsync(RestApiUpgradeChecklUrl, content);
using HttpResponseMessage task = await _httpClient.PostAsync(RestApiUpgradeChecklUrl, content);
var json = await task.Content.ReadAsStringAsync();
UpgradeResult? result = _jsonSerializer.Deserialize<UpgradeResult>(json);