This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from aspriddell/jsonpath-internal
change modern stats JPath handling
- Loading branch information
Showing
9 changed files
with
91 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 9 additions & 18 deletions
27
DragonFruit.Six.Api/Modern/Containers/ModernModeStatsContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,29 @@ | ||
// Dragon6 API Copyright DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Refer to the LICENSE file for more info | ||
|
||
using System; | ||
using DragonFruit.Six.Api.Modern.Enums; | ||
using DragonFruit.Six.Api.Modern.Utils; | ||
using Newtonsoft.Json; | ||
|
||
namespace DragonFruit.Six.Api.Modern.Containers | ||
{ | ||
[JsonPathSerializable] | ||
[JsonObject(MemberSerialization.OptIn)] | ||
[JsonConverter(typeof(JsonPathConverter))] | ||
public class ModernModeStatsContainer<T> | ||
{ | ||
[JsonIgnore] | ||
public ModernRoleStatsContainer<T> this[PlaylistType type] => type switch | ||
{ | ||
PlaylistType.Casual => Casual, | ||
PlaylistType.Ranked => Ranked, | ||
PlaylistType.Unranked => Unranked, | ||
PlaylistType.Independent => AllModes, | ||
|
||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null) | ||
}; | ||
|
||
[JsonProperty("gameModes.all")] | ||
[JsonProperty("all")] | ||
[JsonPath("gameModes.all")] | ||
public ModernRoleStatsContainer<T> AllModes { get; set; } | ||
|
||
[JsonProperty("gameModes.casual")] | ||
[JsonProperty("casual")] | ||
[JsonPath("gameModes.casual")] | ||
public ModernRoleStatsContainer<T> Casual { get; set; } | ||
|
||
[JsonProperty("gameModes.ranked")] | ||
[JsonProperty("ranked")] | ||
[JsonPath("gameModes.ranked")] | ||
public ModernRoleStatsContainer<T> Ranked { get; set; } | ||
|
||
[JsonProperty("gameModes.unranked")] | ||
[JsonProperty("unranked")] | ||
[JsonPath("gameModes.unranked")] | ||
public ModernRoleStatsContainer<T> Unranked { get; set; } | ||
} | ||
} |
22 changes: 7 additions & 15 deletions
22
DragonFruit.Six.Api/Modern/Containers/ModernRoleStatsContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
// Dragon6 API Copyright DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Refer to the LICENSE file for more info | ||
|
||
using System; | ||
using DragonFruit.Six.Api.Enums; | ||
using DragonFruit.Six.Api.Modern.Utils; | ||
using Newtonsoft.Json; | ||
|
||
namespace DragonFruit.Six.Api.Modern.Containers | ||
{ | ||
[JsonPathSerializable] | ||
[JsonObject(MemberSerialization.OptIn)] | ||
[JsonConverter(typeof(JsonPathConverter))] | ||
public class ModernRoleStatsContainer<T> | ||
{ | ||
public T this[OperatorType type] => type switch | ||
{ | ||
OperatorType.Independent => AsAny, | ||
OperatorType.Attacker => AsAttacker, | ||
OperatorType.Defender => AsDefender, | ||
|
||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null) | ||
}; | ||
|
||
[JsonProperty("teamRoles.all")] | ||
[JsonProperty("all")] | ||
[JsonPath("teamRoles.all")] | ||
public T AsAny { get; set; } | ||
|
||
[JsonProperty("teamRoles.attacker")] | ||
[JsonProperty("attacker")] | ||
[JsonPath("teamRoles.attacker")] | ||
public T AsAttacker { get; set; } | ||
|
||
[JsonProperty("teamRoles.defender")] | ||
[JsonProperty("defender")] | ||
[JsonPath("teamRoles.defender")] | ||
public T AsDefender { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Dragon6 API Copyright DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Refer to the LICENSE file for more info | ||
|
||
using System; | ||
|
||
namespace DragonFruit.Six.Api.Modern.Utils | ||
{ | ||
internal class JsonPathAttribute : Attribute | ||
{ | ||
public JsonPathAttribute(string path) | ||
{ | ||
Path = path; | ||
} | ||
|
||
public string Path { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
DragonFruit.Six.Api/Modern/Utils/JsonPathSerializableAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Dragon6 API Copyright DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Refer to the LICENSE file for more info | ||
|
||
using System; | ||
|
||
namespace DragonFruit.Six.Api.Modern.Utils | ||
{ | ||
/// <summary> | ||
/// Marks a class as being able to be deserialized by path reference | ||
/// </summary> | ||
internal class JsonPathSerializableAttribute : Attribute | ||
{ | ||
} | ||
} |