- Null-Prüfung und verzögerte Initialisierung von JsonSerializerOptions entfernt - Standard-JsonSerializerOptions mit PropertyNameCaseInsensitive = true festgelegt - DateTimeConverter immer hinzufügen, wenn JsonSerializerDateFormat festgelegt ist
34 lines
841 B
C#
34 lines
841 B
C#
using System.Text.Json;
|
|
|
|
namespace Leanetec.EConnect.Infrastructure;
|
|
|
|
public class ClientOptions
|
|
{
|
|
public string? BaseAddress { get; set; }
|
|
|
|
public TimeSpan? Timeout { get; set; }
|
|
|
|
public Dictionary<string, string?>? DefaultQueryStrings { get; set; }
|
|
|
|
public Action<HttpClient>? AfterHttpInit { get; set; }
|
|
|
|
private string? _jsonSerializerDateFormat = null;
|
|
|
|
public string? JsonSerializerDateFormat
|
|
{
|
|
get => _jsonSerializerDateFormat;
|
|
set
|
|
{
|
|
_jsonSerializerDateFormat = value;
|
|
if (value is not null)
|
|
{
|
|
JsonSerializerOptions.Converters.Add(new DateTimeConverter(value));
|
|
}
|
|
}
|
|
}
|
|
|
|
public JsonSerializerOptions JsonSerializerOptions { get; set; } = new()
|
|
{
|
|
PropertyNameCaseInsensitive = true
|
|
};
|
|
} |