From facde2c8e17edd2804dfee0921f29caafcd04648 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 May 2020 16:01:07 +0900 Subject: [PATCH] Remove unnecessary generic specification on cursor --- osu.Game/Extensions/WebRequestExtensions.cs | 15 ++++---------- osu.Game/Online/API/Requests/Cursor.cs | 20 +++++++++++++++++++ .../Online/API/Requests/ResponseWithCursor.cs | 11 +--------- .../API/Requests/SearchBeatmapSetsResponse.cs | 3 +-- 4 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 osu.Game/Online/API/Requests/Cursor.cs diff --git a/osu.Game/Extensions/WebRequestExtensions.cs b/osu.Game/Extensions/WebRequestExtensions.cs index 80c8b147bf..b940c7498b 100644 --- a/osu.Game/Extensions/WebRequestExtensions.cs +++ b/osu.Game/Extensions/WebRequestExtensions.cs @@ -3,22 +3,15 @@ using osu.Framework.IO.Network; using osu.Framework.Extensions.IEnumerableExtensions; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using JetBrains.Annotations; +using osu.Game.Online.API.Requests; namespace osu.Game.Extensions { - public class Cursor - { - [UsedImplicitly] - [JsonExtensionData] - public IDictionary Properties; - } - public static class WebRequestExtensions { + /// + /// Add a pagination cursor to the web request in the format required by osu-web. + /// public static void AddCursor(this WebRequest webRequest, Cursor cursor) { cursor?.Properties.ForEach(x => diff --git a/osu.Game/Online/API/Requests/Cursor.cs b/osu.Game/Online/API/Requests/Cursor.cs new file mode 100644 index 0000000000..f21445ca32 --- /dev/null +++ b/osu.Game/Online/API/Requests/Cursor.cs @@ -0,0 +1,20 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using JetBrains.Annotations; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace osu.Game.Online.API.Requests +{ + /// + /// A collection of parameters which should be passed to the search endpoint to fetch the next page. + /// + public class Cursor + { + [UsedImplicitly] + [JsonExtensionData] + public IDictionary Properties; + } +} diff --git a/osu.Game/Online/API/Requests/ResponseWithCursor.cs b/osu.Game/Online/API/Requests/ResponseWithCursor.cs index b0fe9eea28..d52e999722 100644 --- a/osu.Game/Online/API/Requests/ResponseWithCursor.cs +++ b/osu.Game/Online/API/Requests/ResponseWithCursor.cs @@ -7,16 +7,7 @@ namespace osu.Game.Online.API.Requests { public abstract class ResponseWithCursor { - /// - /// A collection of parameters which should be passed to the search endpoint to fetch the next page. - /// [JsonProperty("cursor")] - public dynamic CursorJson; - } - - public abstract class ResponseWithCursor : ResponseWithCursor where T : class - { - [JsonProperty("cursor")] - public T Cursor; + public Cursor Cursor; } } diff --git a/osu.Game/Online/API/Requests/SearchBeatmapSetsResponse.cs b/osu.Game/Online/API/Requests/SearchBeatmapSetsResponse.cs index a4d2c0e871..3c4fb11ed1 100644 --- a/osu.Game/Online/API/Requests/SearchBeatmapSetsResponse.cs +++ b/osu.Game/Online/API/Requests/SearchBeatmapSetsResponse.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using Newtonsoft.Json; -using osu.Game.Extensions; using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class SearchBeatmapSetsResponse : ResponseWithCursor + public class SearchBeatmapSetsResponse : ResponseWithCursor { [JsonProperty("beatmapsets")] public IEnumerable BeatmapSets;