mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-25 15:36:26 +00:00
9dbd210a2f
* Fixed issues #926, and #928. Added JsonConverter attributes to properties. * Fixed complier warning CA1305
22 lines
552 B
C#
22 lines
552 B
C#
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;
|
|
}
|
|
}
|
|
}
|