1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:23:21 +08:00

Merge pull request #1309 from huoyaoyuan/net46

Use .net 4.6 features
This commit is contained in:
Dean Herbert 2017-09-25 13:26:16 +08:00 committed by GitHub
commit 6349c50510
5 changed files with 9 additions and 13 deletions

@ -1 +1 @@
Subproject commit e1352a8b0b5d1ba8acd9335a56c714d2ccc2f6a6
Subproject commit 5f3a7fe4d0537820a33b817a41623b4b22a3ec59

View File

@ -49,7 +49,7 @@ namespace osu.Game.IO.Legacy
int len = ReadInt32();
if (len > 0) return ReadBytes(len);
if (len < 0) return null;
return new byte[0];
return Array.Empty<byte>();
}
/// <summary> Reads a char array from the buffer, handling nulls and the array length. </summary>
@ -58,7 +58,7 @@ namespace osu.Game.IO.Legacy
int len = ReadInt32();
if (len > 0) return ReadChars(len);
if (len < 0) return null;
return new char[0];
return Array.Empty<char>();
}
/// <summary> Reads a DateTime from the buffer. </summary>

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Extensions;
using osu.Framework.IO.Network;
namespace osu.Game.Online.API
@ -70,13 +69,11 @@ namespace osu.Game.Online.API
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
private double remainingTime => Math.Max(0, Timeout - (DateTime.Now.TotalMilliseconds() - (startTime ?? 0)));
private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow - (startTime ?? DateTimeOffset.MinValue)).TotalMilliseconds);
public bool ExceededTimeout => remainingTime == 0;
private double? startTime;
public double StartTime => startTime ?? -1;
private DateTimeOffset? startTime;
protected APIAccess API;
protected WebRequest WebRequest;
@ -96,7 +93,7 @@ namespace osu.Game.Online.API
return;
if (startTime == null)
startTime = DateTime.Now.TotalMilliseconds();
startTime = DateTimeOffset.UtcNow;
if (remainingTime <= 0)
throw new TimeoutException(@"API request timeout hit");

View File

@ -4,7 +4,6 @@
using System;
using System.Globalization;
using Newtonsoft.Json;
using osu.Framework.Extensions;
namespace osu.Game.Online.API
{
@ -22,12 +21,12 @@ namespace osu.Game.Online.API
{
get
{
return AccessTokenExpiry - DateTime.Now.ToUnixTimestamp();
return AccessTokenExpiry - DateTimeOffset.UtcNow.ToUnixTimeSeconds();
}
set
{
AccessTokenExpiry = DateTime.Now.AddSeconds(value).ToUnixTimestamp();
AccessTokenExpiry = DateTimeOffset.Now.AddSeconds(value).ToUnixTimeSeconds();
}
}

View File

@ -127,7 +127,7 @@ namespace osu.Game.Overlays.Mods
if (mod == null)
{
Mods = new Mod[0];
Mods = Array.Empty<Mod>();
Alpha = 0;
}
else