-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance JSON deserialization to include service provider
Updated ReadAsJsonAsync method to accept an IServiceProvider parameter for improved JSON deserialization. Modified corresponding tests and helper classes to utilize the service provider for more flexible JSON serialization options.
- Loading branch information
1 parent
679a051
commit 41e1062
Showing
5 changed files
with
7 additions
and
6 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
...mponent/Elsa.Workflows.ComponentTests/Helpers/Extensions/HttpResponseMessageExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
using System.Text.Json; | ||
using Elsa.Api.Client; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Elsa.Workflows.ComponentTests; | ||
|
||
public static class HttpResponseMessageExtensions | ||
{ | ||
public static async Task<T> ReadAsJsonAsync<T>(this HttpResponseMessage response, CancellationToken cancellationToken = default) | ||
public static async Task<T> ReadAsJsonAsync<T>(this HttpResponseMessage response, IServiceProvider serviceProvider, CancellationToken cancellationToken = default) | ||
{ | ||
var json = await response.Content.ReadAsStringAsync(cancellationToken); | ||
var options = RefitSettingsHelper.CreateJsonSerializerOptions(); | ||
var options = RefitSettingsHelper.CreateJsonSerializerOptions(serviceProvider); | ||
return JsonSerializer.Deserialize<T>(json, options)!; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters