| @@ -2,11 +2,12 @@ | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| [ModelStringEnum] | |||||
| public enum PermissionTarget | public enum PermissionTarget | ||||
| { | { | ||||
| [ModelEnumValue("role")] | [ModelEnumValue("role")] | ||||
| Role, | Role, | ||||
| [ModelEnumValue("user")] | |||||
| [ModelEnumValue("member")] | |||||
| User | User | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,7 +7,6 @@ namespace Discord | |||||
| /// <summary> Gets the unique identifier for the object this overwrite is targeting. </summary> | /// <summary> Gets the unique identifier for the object this overwrite is targeting. </summary> | ||||
| public ulong TargetId { get; } | public ulong TargetId { get; } | ||||
| /// <summary> Gets the type of object this overwrite is targeting. </summary> | /// <summary> Gets the type of object this overwrite is targeting. </summary> | ||||
| [ModelStringEnum] | |||||
| public PermissionTarget TargetType { get; } | public PermissionTarget TargetType { get; } | ||||
| /// <summary> Gets the permissions associated with this overwrite entry. </summary> | /// <summary> Gets the permissions associated with this overwrite entry. </summary> | ||||
| public OverwritePermissions Permissions { get; } | public OverwritePermissions Permissions { get; } | ||||
| @@ -2,6 +2,7 @@ | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| [ModelStringEnum] | |||||
| public enum UserStatus | public enum UserStatus | ||||
| { | { | ||||
| Offline, | Offline, | ||||
| @@ -10,7 +10,6 @@ namespace Discord.API | |||||
| [ModelProperty("guild_id")] | [ModelProperty("guild_id")] | ||||
| public Optional<ulong> GuildId { get; set; } | public Optional<ulong> GuildId { get; set; } | ||||
| [ModelProperty("status")] | [ModelProperty("status")] | ||||
| [ModelStringEnum] | |||||
| public UserStatus Status { get; set; } | public UserStatus Status { get; set; } | ||||
| [ModelProperty("game")] | [ModelProperty("game")] | ||||
| public Game Game { get; set; } | public Game Game { get; set; } | ||||
| @@ -2,7 +2,7 @@ | |||||
| namespace Discord.Serialization | namespace Discord.Serialization | ||||
| { | { | ||||
| [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] | |||||
| [AttributeUsage(AttributeTargets.Enum, AllowMultiple = false)] | |||||
| public class ModelStringEnumAttribute : Attribute | public class ModelStringEnumAttribute : Attribute | ||||
| { | { | ||||
| } | } | ||||
| @@ -52,7 +52,7 @@ namespace Discord.Serialization.Json | |||||
| AddGenericConverter(typeof(Converters.ArrayPropertyConverter<>), //Arrays | AddGenericConverter(typeof(Converters.ArrayPropertyConverter<>), //Arrays | ||||
| (type, prop) => type.IsArray, innerType => innerType.GetElementType()); | (type, prop) => type.IsArray, innerType => innerType.GetElementType()); | ||||
| AddGenericConverter(typeof(Converters.StringEnumPropertyConverter<>), //Enums : string | AddGenericConverter(typeof(Converters.StringEnumPropertyConverter<>), //Enums : string | ||||
| (type, prop) => type.IsEnum && prop.GetCustomAttribute<ModelStringEnumAttribute>() != null); | |||||
| (type, prop) => type.IsEnum && type.GetCustomAttribute<ModelStringEnumAttribute>() != null); | |||||
| AddGenericConverter(typeof(Converters.Int64EnumPropertyConverter<>), //Enums : sbyte/short/int/long | AddGenericConverter(typeof(Converters.Int64EnumPropertyConverter<>), //Enums : sbyte/short/int/long | ||||
| (type, prop) => type.IsEnum && IsSignedEnum(Enum.GetUnderlyingType(type.AsType()))); | (type, prop) => type.IsEnum && IsSignedEnum(Enum.GetUnderlyingType(type.AsType()))); | ||||
| AddGenericConverter(typeof(Converters.UInt64EnumPropertyConverter<>), //Enums: byte/ushort/uint/ulong | AddGenericConverter(typeof(Converters.UInt64EnumPropertyConverter<>), //Enums: byte/ushort/uint/ulong | ||||