Переделано воспроизведение аудио
All checks were successful
Release / pack-and-publish (release) Successful in 36s

This commit is contained in:
2026-04-21 11:14:36 +03:00
parent eb1eba0162
commit 526353d679
12 changed files with 107 additions and 47 deletions

View File

@@ -10,7 +10,17 @@ namespace YandexMusic.API.Requests.Common;
/// </summary>
internal abstract class YJsonRequestBuilder<TResponse, TParams> : YRequestBuilder<TParams>
{
protected YJsonRequestBuilder(YandexMusicApi api) : base(api) { }
private readonly JsonSerializerOptions _jsonOptions;
protected YJsonRequestBuilder(YandexMusicApi api) : base(api)
{
_jsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
}
protected virtual async Task<TResponse?> DeserializeAsync(HttpResponseMessage response)
{
@@ -43,6 +53,8 @@ internal abstract class YJsonRequestBuilder<TResponse, TParams> : YRequestBuilde
}
}
protected string SerializeJson(object data) => JsonSerializer.Serialize(data, _jsonOptions);
/// <summary>
/// Выполняет запрос и возвращает десериализованный объект типа TResponse.
/// </summary>
@@ -51,4 +63,4 @@ internal abstract class YJsonRequestBuilder<TResponse, TParams> : YRequestBuilde
using var response = await ExecuteRawAsync(parameters);
return await DeserializeAsync(response);
}
}
}