Populate json with enums better

This commit is contained in:
Dean Herbert 2018-11-09 17:54:05 +09:00
parent 9064f3fe0f
commit e170372932
2 changed files with 10 additions and 1 deletions

View File

@ -1,21 +1,30 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace osu.Game.Tournament.Screens.Ladder.Components
{
public class BeatmapChoice
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public TeamColour Team;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public ChoiceType Type;
public int BeatmapID;
}
[JsonConverter(typeof(StringEnumConverter))]
public enum TeamColour
{
Red,
Blue
}
[JsonConverter(typeof(StringEnumConverter))]
public enum ChoiceType
{
Pick,

View File

@ -186,7 +186,7 @@ namespace osu.Game.Tournament
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
DefaultValueHandling = DefaultValueHandling.Ignore,
}));
}
}