Обнновлено до .net10

This commit is contained in:
FrigaT
2026-04-10 15:05:32 +03:00
parent 11d0b0d72f
commit 8444fc5f8e
386 changed files with 6361 additions and 7164 deletions

View File

@@ -1,57 +1,12 @@
using YandexMusic.API.Common;
namespace YandexMusic.API.Models.Common
namespace YandexMusic.API.Models.Common;
/// <summary>Контекст выполнения, содержащий ссылки на API и хранилище.</summary>
public class YExecutionContext
{
public sealed class YExecutionContextConverter : JsonConverter
{
#region Поля
private YandexMusicApi api;
private AuthStorage storage;
#endregion Поля
public override bool CanConvert(Type objectType)
{
return typeof(YBaseModel).IsAssignableFrom(objectType);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
try
{
YBaseModel obj = (YBaseModel)Activator.CreateInstance(objectType);
serializer.Populate(reader, obj);
obj.Context = new YExecutionContext
{
API = api,
Storage = storage
};
return obj;
}
catch (Exception ex)
{
throw new Exception($"Ошибка десериализации типа \"{objectType.Name}\".", ex);
}
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public YExecutionContextConverter(YandexMusicApi yandex, AuthStorage auth)
{
api = yandex;
storage = auth;
}
}
public class YExecutionContext
{
public YandexMusicApi API { get; internal set; }
public AuthStorage Storage { get; internal set; }
}
}
/// <summary>Экземпляр основного API.</summary>
public YandexMusicApi API { get; internal set; } = null!;
/// <summary>Хранилище данных авторизации.</summary>
public AuthStorage Storage { get; internal set; } = null!;
}