2020-05-13 23:04:31 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2022-01-04 16:12:34 +08:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
2020-05-13 23:04:31 +08:00
|
|
|
|
using osu.Framework.IO.Network;
|
2020-05-13 04:04:39 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2020-05-14 15:01:07 +08:00
|
|
|
|
using osu.Game.Online.API.Requests;
|
2020-05-13 04:04:39 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Extensions
|
|
|
|
|
{
|
|
|
|
|
public static class WebRequestExtensions
|
|
|
|
|
{
|
2020-05-14 15:01:07 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add a pagination cursor to the web request in the format required by osu-web.
|
|
|
|
|
/// </summary>
|
2020-05-13 04:04:39 +08:00
|
|
|
|
public static void AddCursor(this WebRequest webRequest, Cursor cursor)
|
|
|
|
|
{
|
2022-06-30 23:29:49 +08:00
|
|
|
|
cursor.Properties.ForEach(x =>
|
2020-05-13 04:04:39 +08:00
|
|
|
|
{
|
2022-01-04 16:12:34 +08:00
|
|
|
|
webRequest.AddParameter("cursor[" + x.Key + "]", (x.Value as JValue)?.ToString(CultureInfo.InvariantCulture) ?? x.Value.ToString());
|
2020-05-13 04:04:39 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|