Browse Source

Changed GameId from string to nullable int

pull/12/merge
RogueException 9 years ago
parent
commit
c910523788
5 changed files with 4 additions and 52 deletions
  1. +0
    -3
      src/Discord.Net.Net45/Discord.Net.csproj
  2. +0
    -37
      src/Discord.Net/API/Converters/ShortStringConverter.cs
  3. +1
    -1
      src/Discord.Net/API/Members.cs
  4. +2
    -10
      src/Discord.Net/Helpers/IdConvert.cs
  5. +1
    -1
      src/Discord.Net/Models/User.cs

+ 0
- 3
src/Discord.Net.Net45/Discord.Net.csproj View File

@@ -82,9 +82,6 @@
<Compile Include="..\Discord.Net\API\Converters\LongStringConverter.cs">
<Link>API\Converters\LongStringConverter.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\API\Converters\ShortStringConverter.cs">
<Link>API\Converters\ShortStringConverter.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\API\Endpoints.cs">
<Link>API\Endpoints.cs</Link>
</Compile>


+ 0
- 37
src/Discord.Net/API/Converters/ShortStringConverter.cs View File

@@ -1,37 +0,0 @@
using Newtonsoft.Json;
using System;

namespace Discord.API.Converters
{
/*internal class ShortStringConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(short);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return IdConvert.ToShort((string)reader.Value);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(IdConvert.ToString((short)value));
}
}

internal class NullableShortStringConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(short?);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return IdConvert.ToNullableShort((string)reader.Value);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(IdConvert.ToString((short?)value));
}
}*/
}

+ 1
- 1
src/Discord.Net/API/Members.cs View File

@@ -49,7 +49,7 @@ namespace Discord.API
public class PresenceInfo : MemberReference
{
[JsonProperty("game_id")]
public string GameId;
public int? GameId;
[JsonProperty("status")]
public string Status;
[JsonProperty("roles")] //TODO: Might be temporary


+ 2
- 10
src/Discord.Net/Helpers/IdConvert.cs View File

@@ -6,20 +6,12 @@ namespace Discord
internal static class IdConvert
{
internal static readonly IFormatProvider _format = CultureInfo.InvariantCulture;

public static short ToShort(string value)
=> short.Parse(value, NumberStyles.None, _format);
public static short? ToNullableShort(string value)
=> value == null ? (short?)null : short.Parse(value, NumberStyles.None, _format);
public static long ToLong(string value)
=> long.Parse(value, NumberStyles.None, _format);
public static long? ToNullableLong(string value)
=> value == null ? (long?)null : long.Parse(value, NumberStyles.None, _format);

public static string ToString(short value)
=> value.ToString(_format);
public static string ToString(short? value)
=> value?.ToString(_format);
public static string ToString(long value)
=> value.ToString(_format);
public static string ToString(long? value)


+ 1
- 1
src/Discord.Net/Models/User.cs View File

@@ -67,7 +67,7 @@ namespace Discord
public string Token { get; private set; }

/// <summary> Returns the id for the game this user is currently playing. </summary>
public string GameId { get; private set; }
public int? GameId { get; private set; }
/// <summary> Returns the current status for this user. </summary>
public UserStatus Status { get; private set; }
/// <summary> Returns the time this user last sent/edited a message, started typing or sent voice data in this server. </summary>


Loading…
Cancel
Save