mirror of
https://github.com/ppy/osu.git
synced 2024-12-25 03:22:57 +08:00
5736b7d978
Fixed as per solution at https://github.com/JamesNK/Newtonsoft.Json/issues/874. Note that due to the use of `JsonExtensionDataAttribute` it's not feasible to change the actual specification to `JValue` in the `Dictionary`. In discussion with the osu-web team, it may be worthwhile to change the cursor to a string format where parsing is not required at our end. We could already do this in fact, but there are tests that rely on it being a `JToken` so the switch to `JValue` seems like the easier path right now.
26 lines
881 B
C#
26 lines
881 B
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System.Globalization;
|
|
using Newtonsoft.Json.Linq;
|
|
using osu.Framework.IO.Network;
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
namespace osu.Game.Extensions
|
|
{
|
|
public static class WebRequestExtensions
|
|
{
|
|
/// <summary>
|
|
/// Add a pagination cursor to the web request in the format required by osu-web.
|
|
/// </summary>
|
|
public static void AddCursor(this WebRequest webRequest, Cursor cursor)
|
|
{
|
|
cursor?.Properties.ForEach(x =>
|
|
{
|
|
webRequest.AddParameter("cursor[" + x.Key + "]", (x.Value as JValue)?.ToString(CultureInfo.InvariantCulture) ?? x.Value.ToString());
|
|
});
|
|
}
|
|
}
|
|
}
|