| @@ -65,13 +65,13 @@ namespace Discord.Serialization | |||||
| throw new SerializationException("Failed to parse UInt64"); | throw new SerializationException("Failed to parse UInt64"); | ||||
| } | } | ||||
| public static char ParseChar(this ReadOnlySpan<byte> text) | |||||
| /*public static char ParseChar(this ReadOnlySpan<byte> text) | |||||
| { | { | ||||
| string str = ParseString(text); | string str = ParseString(text); | ||||
| if (str.Length == 1) | |||||
| return str[0]; | |||||
| if (char.TryParse(str, out char c)) | |||||
| return c; | |||||
| throw new SerializationException("Failed to parse Char"); | throw new SerializationException("Failed to parse Char"); | ||||
| } | |||||
| }*/ | |||||
| public static string ParseString(this ReadOnlySpan<byte> text) => new Utf8String(text).ToString(); | public static string ParseString(this ReadOnlySpan<byte> text) => new Utf8String(text).ToString(); | ||||
| public static float ParseSingle(this ReadOnlySpan<byte> text) | public static float ParseSingle(this ReadOnlySpan<byte> text) | ||||
| @@ -17,7 +17,7 @@ namespace Discord.Serialization | |||||
| public static uint ParseUInt32(this JsonReader reader) => reader.Value.ParseUInt32(); | public static uint ParseUInt32(this JsonReader reader) => reader.Value.ParseUInt32(); | ||||
| public static ulong ParseUInt64(this JsonReader reader) => reader.Value.ParseUInt64(); | public static ulong ParseUInt64(this JsonReader reader) => reader.Value.ParseUInt64(); | ||||
| public static char ParseChar(this JsonReader reader) => reader.Value.ParseChar(); | |||||
| //public static char ParseChar(this JsonReader reader) => reader.Value.ParseChar(); | |||||
| public static string ParseString(this JsonReader reader) => reader.Value.ParseString(); | public static string ParseString(this JsonReader reader) => reader.Value.ParseString(); | ||||
| public static float ParseSingle(this JsonReader reader) => reader.Value.ParseSingle(); | public static float ParseSingle(this JsonReader reader) => reader.Value.ParseSingle(); | ||||
| @@ -2,7 +2,7 @@ | |||||
| namespace Discord.Serialization.Json.Converters | namespace Discord.Serialization.Json.Converters | ||||
| { | { | ||||
| internal class CharPropertyConverter : IJsonPropertyConverter<char> | |||||
| /*internal class CharPropertyConverter : IJsonPropertyConverter<char> | |||||
| { | { | ||||
| public char Read(PropertyMap map, JsonReader reader, bool isTopLevel) | public char Read(PropertyMap map, JsonReader reader, bool isTopLevel) | ||||
| { | { | ||||
| @@ -19,7 +19,7 @@ namespace Discord.Serialization.Json.Converters | |||||
| else | else | ||||
| writer.WriteValue(value.ToString()); | writer.WriteValue(value.ToString()); | ||||
| } | } | ||||
| } | |||||
| }*/ | |||||
| internal class StringPropertyConverter : IJsonPropertyConverter<string> | internal class StringPropertyConverter : IJsonPropertyConverter<string> | ||||
| { | { | ||||
| @@ -25,8 +25,8 @@ namespace Discord.Serialization.Json | |||||
| AddConverter<float, Converters.SinglePropertyConverter>(); | AddConverter<float, Converters.SinglePropertyConverter>(); | ||||
| AddConverter<double, Converters.DoublePropertyConverter>(); | AddConverter<double, Converters.DoublePropertyConverter>(); | ||||
| AddConverter<decimal, Converters.DecimalPropertyConverter>(); | AddConverter<decimal, Converters.DecimalPropertyConverter>(); | ||||
| AddConverter<char, Converters.CharPropertyConverter>(); | |||||
| //AddConverter<char, Converters.CharPropertyConverter>(); //char.Parse does not support Json.Net's serialization | |||||
| AddConverter<string, Converters.StringPropertyConverter>(); | AddConverter<string, Converters.StringPropertyConverter>(); | ||||
| AddConverter<DateTime, Converters.DateTimePropertyConverter>(); | AddConverter<DateTime, Converters.DateTimePropertyConverter>(); | ||||
| @@ -38,9 +38,8 @@ namespace Discord.Serialization.Json | |||||
| AddGenericConverter(typeof(List<>), typeof(Converters.ListPropertyConverter<>)); | AddGenericConverter(typeof(List<>), typeof(Converters.ListPropertyConverter<>)); | ||||
| AddGenericConverter(typeof(Nullable<>), typeof(Converters.NullablePropertyConverter<>)); | AddGenericConverter(typeof(Nullable<>), typeof(Converters.NullablePropertyConverter<>)); | ||||
| //AddGenericConverter(typeof(Converters.EnumPropertyConverter<>), (type, prop) => type.IsEnum); //TODO: Impl Enums | |||||
| AddGenericConverter(typeof(Converters.ObjectPropertyConverter<>), (type, prop) => type.IsClass); | AddGenericConverter(typeof(Converters.ObjectPropertyConverter<>), (type, prop) => type.IsClass); | ||||
| //AddEnumConverter<Converters.EnumPropertyConverter>(); | |||||
| } | } | ||||
| public void AddConverter<TValue, TConverter>() | public void AddConverter<TValue, TConverter>() | ||||