mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2025-01-11 06:07:45 +00:00
* Fixed issues #926, and #928. Added JsonConverter attributes to properties. * Fixed complier warning CA1305
This commit is contained in:
parent
0fe33df65a
commit
9dbd210a2f
21
SpotifyAPI.Web/Models/Converters/DoubleToIntConverter.cs
Normal file
21
SpotifyAPI.Web/Models/Converters/DoubleToIntConverter.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace SpotifyAPI.Web
|
||||||
|
{
|
||||||
|
public class DoubleToIntConverter : JsonConverter<int>
|
||||||
|
{
|
||||||
|
public override void WriteJson(JsonWriter? writer, int value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
writer?.WriteValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int ReadJson(JsonReader? reader, Type objectType, int existingValue, bool hasExistingValue,
|
||||||
|
JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
return reader != null ? Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
public class Followers
|
public class Followers
|
||||||
{
|
{
|
||||||
public string Href { get; set; } = default!;
|
public string Href { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonConverter(typeof(DoubleToIntConverter))]
|
||||||
public int Total { get; set; }
|
public int Total { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
@ -11,6 +12,7 @@ namespace SpotifyAPI.Web
|
|||||||
public string Id { get; set; } = default!;
|
public string Id { get; set; } = default!;
|
||||||
public List<Image> Images { get; set; } = default!;
|
public List<Image> Images { get; set; } = default!;
|
||||||
public string Name { get; set; } = default!;
|
public string Name { get; set; } = default!;
|
||||||
|
[JsonConverter(typeof(DoubleToIntConverter))]
|
||||||
public int Popularity { get; set; }
|
public int Popularity { get; set; }
|
||||||
public string Type { get; set; } = default!;
|
public string Type { get; set; } = default!;
|
||||||
public string Uri { get; set; } = default!;
|
public string Uri { get; set; } = default!;
|
||||||
|
@ -10,6 +10,7 @@ namespace SpotifyAPI.Web
|
|||||||
public List<SimpleArtist> Artists { get; set; } = default!;
|
public List<SimpleArtist> Artists { get; set; } = default!;
|
||||||
public List<string> AvailableMarkets { get; set; } = default!;
|
public List<string> AvailableMarkets { get; set; } = default!;
|
||||||
public int DiscNumber { get; set; }
|
public int DiscNumber { get; set; }
|
||||||
|
[JsonConverter(typeof(DoubleToIntConverter))]
|
||||||
public int DurationMs { get; set; }
|
public int DurationMs { get; set; }
|
||||||
public bool Explicit { get; set; }
|
public bool Explicit { get; set; }
|
||||||
public Dictionary<string, string> ExternalIds { get; set; } = default!;
|
public Dictionary<string, string> ExternalIds { get; set; } = default!;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
public class Image
|
public class Image
|
||||||
{
|
{
|
||||||
|
[JsonConverter(typeof(DoubleToIntConverter))]
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
[JsonConverter(typeof(DoubleToIntConverter))]
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public string Url { get; set; } = default!;
|
public string Url { get; set; } = default!;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user