Добавьте файлы проекта.

This commit is contained in:
FrigaT
2026-04-10 12:12:33 +03:00
parent 9615cf42ee
commit 11d0b0d72f
383 changed files with 9661 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
{
public sealed class YPlayContextConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(YLandingEntity).IsAssignableFrom(objectType);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
return null;
JObject jObject = JObject.Load(reader);
YPlayContext context;
try
{
YPlayContextType type = jObject["context"].ToObject<YPlayContextType>();
switch (type)
{
case YPlayContextType.Album:
context = jObject.ToObject<YPlayContextAlbum>();
break;
case YPlayContextType.Artist:
context = jObject.ToObject<YPlayContextArtist>();
break;
case YPlayContextType.Playlist:
context = jObject.ToObject<YPlayContextPlaylist>();
break;
default:
context = jObject.ToObject<YPlayContext>();
break;
}
}
catch (Exception ex)
{
throw new Exception($"Ошибка десериализации типа \"{jObject["type"]}\".", ex);
}
return context;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
public class YPlayContext
{
public string Client { get; set; }
public YPlayContextType Context { get; set; }
public string ContextItem { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
using YandexMusic.API.Models.Album;
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
{
public class YPlayContextAlbum : YPlayContext
{
public YAlbum Payload { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
using YandexMusic.API.Models.Artist;
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
{
public class YPlayContextArtist : YPlayContext
{
public YArtist Payload { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
using YandexMusic.API.Models.Playlist;
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
{
public class YPlayContextPlaylist : YPlayContext
{
public YPlaylist Payload { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
{
public enum YPlayContextType
{
Album,
Artist,
Playlist
}
}