diff --git a/osuElements/Api/Repositories/ApiBeatmapRepository.cs b/osuElements/Api/Repositories/ApiBeatmapRepository.cs index f1fba96..bcffe91 100644 --- a/osuElements/Api/Repositories/ApiBeatmapRepository.cs +++ b/osuElements/Api/Repositories/ApiBeatmapRepository.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using osuElements.Api.Throttling; using osuElements.Helpers; using static osuElements.Helpers.Constants; @@ -9,17 +10,12 @@ namespace osuElements.Api.Repositories { public class ApiBeatmapRepository : ApiRepositoryBase, IApiBeatmapRepository { - Lazy _apiScoreRepository; - public ApiBeatmapRepository() - { - _apiScoreRepository = new Lazy(() => new ApiScoreRepository(), true); - } + public ApiBeatmapRepository() : base() { } + + public ApiBeatmapRepository(string apiKey, bool throwExceptions, IThrottler throttler) : base(apiKey, throwExceptions, throttler) { } + - public ApiBeatmapRepository(IApiScoreRepository apiScoreRepository) - { - _apiScoreRepository = new Lazy(() => apiScoreRepository, true); - } public async Task> GetSince(DateTime time, GameMode? mode = null, int limit = MaxApiBeatmapResults) { return await GetMaps( @@ -53,20 +49,6 @@ public async Task Get(string mapHash, GameMode? mode = null) { return (await GetMaps($"get_beatmaps?h={mapHash}", mode))?.FirstOrDefault(); } - // Left for backward compatibility - public async Task> GetScores(int mapId, int? userid = null, string username = null, - GameMode mode = 0, Mods? mods = null, int limit = MaxApiBeatmapResults) { - - if (userid.HasValue) { - return await CallNestedRepository(_apiScoreRepository.Value, async (repo) => await - repo.GetMapScores(mapId, userid.Value, mode, mods, limit)); - } - else { - return await CallNestedRepository(_apiScoreRepository.Value, async (repo) => await - repo.GetMapScores(mapId, username, mode, mods, limit)); - } - - } private async Task> GetMaps(string query, GameMode? mode) { var modestring = mode.HasValue && mode.Value != GameMode.Standard ? $"&m={(int)mode.Value}&a=1" : ""; diff --git a/osuElements/Api/Repositories/ApiMultiplayerRepository.cs b/osuElements/Api/Repositories/ApiMultiplayerRepository.cs index fb80988..6ef9352 100644 --- a/osuElements/Api/Repositories/ApiMultiplayerRepository.cs +++ b/osuElements/Api/Repositories/ApiMultiplayerRepository.cs @@ -1,10 +1,18 @@ using System.Linq; using System.Threading.Tasks; +using osuElements.Api.Throttling; namespace osuElements.Api.Repositories { public class ApiMultiplayerRepository : ApiRepositoryBase, IApiMultiplayerRepository { + + public ApiMultiplayerRepository() : base() { } + + public ApiMultiplayerRepository(string apiKey, bool throwExceptions, IThrottler throttler) : base(apiKey, throwExceptions, throttler) { } + + + public async Task Get(int matchId) { var result = (await GetList($"get_match?id={matchId}"))?.FirstOrDefault(); if (result == null) return null; diff --git a/osuElements/Api/Repositories/ApiReplayRepository.cs b/osuElements/Api/Repositories/ApiReplayRepository.cs index 20b8b49..cd18437 100644 --- a/osuElements/Api/Repositories/ApiReplayRepository.cs +++ b/osuElements/Api/Repositories/ApiReplayRepository.cs @@ -2,11 +2,19 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; +using osuElements.Api.Throttling; namespace osuElements.Api.Repositories { public class ApiReplayRepository: ApiRepositoryBase, IApiReplayRepository { + + public ApiReplayRepository() : base() { } + + public ApiReplayRepository(string apiKey, bool throwExceptions, IThrottler throttler) : base(apiKey, throwExceptions, throttler) { } + + + public async Task Get(int mapId, int userId, GameMode mode) { return await GetData($"get_replay?b={mapId}&u={userId}&m={(int) mode}"); } diff --git a/osuElements/Api/Repositories/ApiRepositoryBase.cs b/osuElements/Api/Repositories/ApiRepositoryBase.cs index 72a3906..957a7b9 100644 --- a/osuElements/Api/Repositories/ApiRepositoryBase.cs +++ b/osuElements/Api/Repositories/ApiRepositoryBase.cs @@ -9,24 +9,38 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using osuElements.Api.Throttling; namespace osuElements.Api.Repositories { public abstract class ApiRepositoryBase : IApiRepository { + private readonly IThrottler _throttler; + #region Properties public static string Url { get; } = "https://osu.ppy.sh/api/"; - public static string Key { protected get; set; } - - public static bool ThrowExceptionsDefault { get; set; } = false; + public string Key { get; set; } - public static bool ThrowExceptions { get; set; } = ThrowExceptionsDefault; + public bool ThrowExceptions { get; set; } public bool IsError { get; protected set; } public ApiError ApiError { get; protected set; } #endregion + public ApiRepositoryBase(string apiKey, bool throwExceptions, IThrottler throttler) + { + Key = apiKey; + ThrowExceptions = throwExceptions; + _throttler = throttler; + } + + public ApiRepositoryBase() + { + Key = osuElements.ApiKey; + ThrowExceptions = osuElements.ApiRepositoryThrowExceptions; + _throttler = osuElements.ApiRepositoryThrottler; + } #region GetList @@ -50,7 +64,10 @@ protected async Task GetData(string query) { string jsonResult = null; using (var client = new HttpClient()) { - + + if (_throttler != null) + await _throttler.WaitAsync(); + var response = await client.GetAsync(url); jsonResult = await response.Content.ReadAsStringAsync(); @@ -77,24 +94,6 @@ protected async Task GetData(string query) { #endregion - #region CallNestedRepository - - protected TResult CallNestedRepository(TRepository repo, Func callFunc) - where TRepository : IApiRepository - { - try { - return callFunc(repo); - } - catch { - throw; - } - finally { - SetError(repo.IsError, repo.ApiError); - } - } - - #endregion - #region SetError @@ -120,10 +119,6 @@ protected virtual void SetError(string jsonResult) { } } - #endregion - - #region SetError - protected virtual void SetError(bool isError, ApiError apiError) { IsError = isError; ApiError = apiError; diff --git a/osuElements/Api/Repositories/ApiScoreRepository.cs b/osuElements/Api/Repositories/ApiScoreRepository.cs index 68f0356..6800c14 100644 --- a/osuElements/Api/Repositories/ApiScoreRepository.cs +++ b/osuElements/Api/Repositories/ApiScoreRepository.cs @@ -1,15 +1,23 @@ -using osuElements.Helpers; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static osuElements.Helpers.Constants; +using osuElements.Api.Throttling; +using osuElements.Helpers; namespace osuElements.Api.Repositories { public class ApiScoreRepository : ApiRepositoryBase, IApiScoreRepository { + + public ApiScoreRepository() : base() { } + + public ApiScoreRepository(string apiKey, bool throwExceptions, IThrottler throttler) : base(apiKey, throwExceptions, throttler) { } + + + public async Task> GetMapScores(int mapId, int userid, GameMode mode = GameMode.Standard, Mods? mods = null, int limit = MaxApiScoreResults) { var modstring = mods.HasValue ? $"&mods={(int)mods.Value}" : ""; diff --git a/osuElements/Api/Repositories/ApiUserRepository.cs b/osuElements/Api/Repositories/ApiUserRepository.cs index cd3b7d6..b801327 100644 --- a/osuElements/Api/Repositories/ApiUserRepository.cs +++ b/osuElements/Api/Repositories/ApiUserRepository.cs @@ -3,25 +3,20 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using osuElements.Api.Throttling; using osuElements.Helpers; -using static osuElements.GameMode; using static osuElements.Helpers.Constants; namespace osuElements.Api.Repositories { public class ApiUserRepository : ApiRepositoryBase, IApiUserRepository { - Lazy _apiScoreRepository; - public ApiUserRepository() - { - _apiScoreRepository = new Lazy(() => new ApiScoreRepository(), true); - } + public ApiUserRepository() : base() { } + + public ApiUserRepository(string apiKey, bool throwExceptions, IThrottler throttler) : base(apiKey, throwExceptions, throttler) { } + - public ApiUserRepository(IApiScoreRepository apiScoreRepository) - { - _apiScoreRepository = new Lazy(() => apiScoreRepository, true); - } public async Task Get(string name, GameMode mode = 0, int eventDays = MaxApiEventDays) { @@ -47,30 +42,5 @@ public async Task Get(int id, GameMode mode = 0, int eventDays = MaxApi return result; } - // Methods below left for backward compatibility - - public async Task> GetBest(int id, GameMode mode = Standard, int limit = MaxApiScoreResults) - { - return await CallNestedRepository(_apiScoreRepository.Value, async (repo) => await - repo.GetUserBest(id, mode, limit)); - } - - public async Task> GetBest(string name, GameMode mode = Standard, int limit = MaxApiScoreResults) - { - return await CallNestedRepository(_apiScoreRepository.Value, async (repo) => await - repo.GetUserBest(name, mode, limit)); - } - - public async Task> GetRecent(int id, GameMode mode = Standard, int limit = MaxApiScoreResults) - { - return await CallNestedRepository(_apiScoreRepository.Value, async (repo) => await - repo.GetUserBest(id, mode, limit)); - } - - public async Task> GetRecent(string name, GameMode mode = Standard, int limit = MaxApiScoreResults) - { - return await CallNestedRepository(_apiScoreRepository.Value, async (repo) => await - repo.GetUserBest(name, mode, limit)); - } } } \ No newline at end of file diff --git a/osuElements/Api/Repositories/IApiRepository.cs b/osuElements/Api/Repositories/IApiRepository.cs index 4214b8c..e3a3512 100644 --- a/osuElements/Api/Repositories/IApiRepository.cs +++ b/osuElements/Api/Repositories/IApiRepository.cs @@ -38,37 +38,6 @@ public interface IApiUserRepository : IApiRepository /// the gamemode for the data /// max amount of days for the event data, between 1 and 31 Task Get(int id, GameMode mode = Standard, int eventDays = MaxApiEventDays); - - /// - /// Returns the top scores for the specified user. - /// - /// username, cannot be ID - /// the gamemode for the data - /// max amount of results, between 1 and 100 - Task> GetBest(string name, GameMode mode = Standard, int limit = MaxApiScoreResults); - /// - /// Returns the top scores for the specified user. - /// - /// user ID, cannot be name - /// the gamemode for the data - /// max amount of results, between 1 and 100 - Task> GetBest(int id, GameMode mode = Standard, int limit = MaxApiScoreResults); - - /// - /// Returns most recent scores for the specified user. - /// - /// username, cannot be ID - /// the gamemode for the data - /// max amount of results, between 1 and 100 - Task> GetRecent(string name, GameMode mode = Standard, int limit = MaxApiScoreResults); - - /// - /// Returns most recent scores for the specified user. - /// - /// user ID, cannot be name - /// the gamemode for the data - /// max amount of results, between 1 and 100 - Task> GetRecent(int id, GameMode mode = Standard, int limit = MaxApiScoreResults); } public interface IApiBeatmapRepository : IApiRepository @@ -113,16 +82,6 @@ public interface IApiBeatmapRepository : IApiRepository /// the beatmap hash /// optional, only gamemode to return results from Task Get(string mapHash, GameMode? mode = null); - /// - /// Returns the top scores for the specified beatmap. - /// - /// beatmap ID - /// optional, specify a user's ID to get a score for - /// optional, specify a user's username to get a score for - /// optional, specify a gamemode to get scores for - /// optional, specify mods to get scores for - /// max amount of results, between 1 and 100 - Task> GetScores(int mapId, int? userid = null, string username = null, GameMode mode = Standard, Mods? mods = null, int limit = MaxApiScoreResults); } public interface IApiReplayRepository : IApiRepository @@ -154,16 +113,56 @@ public interface IApiMultiplayerRepository : IApiRepository public interface IApiScoreRepository : IApiRepository { + /// + /// Returns the top scores for the specified user. + /// + /// user ID, cannot be name + /// the gamemode for the data + /// max amount of results, between 1 and 100 Task> GetUserBest(int userId, GameMode mode = Standard, int limit = MaxApiScoreResults); + /// + /// Returns the top scores for the specified user. + /// + /// username, cannot be ID + /// the gamemode for the data + /// max amount of results, between 1 and 100 Task> GetUserBest(string userName, GameMode mode = Standard, int limit = MaxApiScoreResults); + /// + /// Returns most recent scores for the specified user. + /// + /// user ID, cannot be name + /// the gamemode for the data + /// max amount of results, between 1 and 100 Task> GetUserRecent(int userId, GameMode mode = Standard, int limit = MaxApiScoreResults); + /// + /// Returns most recent scores for the specified user. + /// + /// username, cannot be ID + /// the gamemode for the data + /// max amount of results, between 1 and 100 Task> GetUserRecent(string userName, GameMode mode = Standard, int limit = MaxApiScoreResults); - Task> GetMapScores(int mapId, string username = null, GameMode mode = Standard, Mods? mods = null, int limit = MaxApiScoreResults); + /// + /// Returns the top scores for the specified beatmap. + /// + /// beatmap ID + /// optional, specify a user's username to get a score for + /// optional, specify a gamemode to get scores for + /// optional, specify mods to get scores for + /// max amount of results, between 1 and 100 + Task> GetMapScores(int mapId, string userName = null, GameMode mode = Standard, Mods? mods = null, int limit = MaxApiScoreResults); - Task> GetMapScores(int mapId, int userid, GameMode mode = Standard, Mods? mods = null, int limit = MaxApiScoreResults); + /// + /// Returns the top scores for the specified beatmap. + /// + /// beatmap ID + /// optional, specify a user's ID to get a score for + /// optional, specify a gamemode to get scores for + /// optional, specify mods to get scores for + /// max amount of results, between 1 and 100 + Task> GetMapScores(int mapId, int userId, GameMode mode = Standard, Mods? mods = null, int limit = MaxApiScoreResults); } } \ No newline at end of file diff --git a/osuElements/Api/Throttling/IThrottler.cs b/osuElements/Api/Throttling/IThrottler.cs new file mode 100644 index 0000000..a8485f3 --- /dev/null +++ b/osuElements/Api/Throttling/IThrottler.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace osuElements.Api.Throttling +{ + public interface IThrottler: IDisposable + { + Task WaitAsync(); + } +} diff --git a/osuElements/Api/Throttling/NoThrottler.cs b/osuElements/Api/Throttling/NoThrottler.cs new file mode 100644 index 0000000..c1eb642 --- /dev/null +++ b/osuElements/Api/Throttling/NoThrottler.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace osuElements.Api.Throttling +{ + public class NoThrottler: IThrottler + { + private bool _disposedValue; + + public Task WaitAsync() => Task.FromResult(true); + + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) + { + _disposedValue = true; + } + } + + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } +} diff --git a/osuElements/Api/Throttling/TimerThrottler.cs b/osuElements/Api/Throttling/TimerThrottler.cs new file mode 100644 index 0000000..552a0d7 --- /dev/null +++ b/osuElements/Api/Throttling/TimerThrottler.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace osuElements.Api.Throttling +{ + public class TimerThrottler: IThrottler + { + + readonly SemaphoreSlim _waitSemaphore = new SemaphoreSlim(1, 1); + + readonly Timer _resetTimer; + readonly TimeSpan _cooldown; + private bool _disposedValue; + + public TimerThrottler(TimeSpan cooldown) + { + _cooldown = cooldown; + _resetTimer = new Timer(_ => _waitSemaphore.Release(), null, Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan); + } + + public TimerThrottler(int actions, TimeSpan perTime) + : this(TimeSpan.FromMilliseconds(perTime.TotalMilliseconds / actions)) + { + + } + + + + public async Task WaitAsync() + { + await _waitSemaphore.WaitAsync(); + if (!_resetTimer.Change(_cooldown, Timeout.InfiniteTimeSpan)) + throw new Exception("Timer update error"); + } + + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + _resetTimer.Dispose(); + _waitSemaphore.Dispose(); + } + + _disposedValue = true; + } + } + + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } +} diff --git a/osuElements/Db/DbBeatmap.cs b/osuElements/Db/DbBeatmap.cs index b9b20c7..c34a543 100644 --- a/osuElements/Db/DbBeatmap.cs +++ b/osuElements/Db/DbBeatmap.cs @@ -7,14 +7,15 @@ namespace osuElements.Db { public enum DbBeatmapState { - None, - Unsubmitted, - Graveyard, - WorkInProgress, - Ranked, - Approved, - Qualified, + None = 0, + Unsubmitted = 1, + Pending = 2, WorkInProgress = 2, Graveyard = 2, + Ranked = 4, + Approved = 5, + Qualified = 6, + Loved = 7 } + /// /// The database-driven approach to the beatmap object /// @@ -53,10 +54,7 @@ public DbBeatmap() { public bool Unplayed { get; set; } public bool Osz2 { get; set; } public byte ManiaScrollSpeed { get; set; } - public int ByteLength { get; set; } //the length in bytes of this data in the database - - //Unsure - public int Int { get; set; } //nearly always 0 - public bool Bool2 { get; set; } //nearly always false + public int LastModificationTime { get; set; } + public bool VisualOverride { get; set; } } } \ No newline at end of file diff --git a/osuElements/Db/OsuDb.cs b/osuElements/Db/OsuDb.cs index 907c8c6..de62c35 100644 --- a/osuElements/Db/OsuDb.cs +++ b/osuElements/Db/OsuDb.cs @@ -10,6 +10,19 @@ namespace osuElements.Db { + + [Flags] + public enum OsuUserPersissions + { + None = 0, + Normal = 1, + Moderator = 2, + Supporter = 4, + Friend = 8, + Peppy = 16, + WorldCupStaff = 32 + } + public class OsuDb { public OsuDb() { @@ -19,9 +32,8 @@ public OsuDb() { public int CollectionCount { get; set; } public string UserName { get; set; } public List Beatmaps { get; set; } - //unsure - public int SomeInt { get; set; } - public bool SomeBool { get; set; } + public OsuUserPersissions UserPermissions { get; set; } + public bool AccountUnlocked { get; set; } public DateTime DateTime { get; set; } #region File @@ -53,11 +65,10 @@ public static BinaryFile FileReader() { var result = new BinaryFile( new BinaryFileLine(s => s.FileVersion), new BinaryFileLine(s => s.CollectionCount), - new BinaryFileLine(s => s.SomeBool), + new BinaryFileLine(s => s.AccountUnlocked), new BinaryFileLine(s => s.DateTime), new BinaryFileLine(s => s.UserName), new BinaryCollection(s => s.Beatmaps, - new BinaryFileLine(b => b.ByteLength), new BinaryFileLine(b => b.Artist), new BinaryFileLine(b => b.ArtistUnicode), new BinaryFileLine(b => b.Title), @@ -77,9 +88,7 @@ public static BinaryFile FileReader() { new BinaryFileLine(b => b.DifficultyHpDrainRate), new BinaryFileLine(b => b.DifficultyOverall), new BinaryFileLine(b => b.DifficultySliderMultiplier), - new BinaryFileDictionary(b => b.StandardDifficulties) { - KeyType = typeof(int) - }, + new BinaryFileDictionary(b => b.StandardDifficulties) { KeyType = typeof(int) }, new BinaryFileDictionary(b => b.TaikoDifficulties) { KeyType = typeof(int) }, new BinaryFileDictionary(b => b.CtbDifficulties) { KeyType = typeof(int) }, new BinaryFileDictionary(b => b.ManiaDifficulties) { KeyType = typeof(int) }, @@ -113,12 +122,12 @@ public static BinaryFile FileReader() { new BinaryFileLine(b => b.IgnoreSkin), new BinaryFileLine(b => b.IgnoreStoryboard), new BinaryFileLine(b => b.IgnoreVideo), - new BinaryFileLine(b => b.Bool2), - new BinaryFileLine(b => b.Int), + new BinaryFileLine(b => b.VisualOverride), + new BinaryFileLine(b => b.LastModificationTime), new BinaryFileLine(b => b.ManiaScrollSpeed) ), - new BinaryFileLine(s => s.SomeInt) + new BinaryFileLine(s => s.UserPermissions) { Type = typeof(int) } ); return result; } diff --git a/osuElements/IO/Binary/BinaryFileLine.cs b/osuElements/IO/Binary/BinaryFileLine.cs index b305757..670e087 100644 --- a/osuElements/IO/Binary/BinaryFileLine.cs +++ b/osuElements/IO/Binary/BinaryFileLine.cs @@ -38,7 +38,13 @@ public virtual void WriteValue(BinaryWriter writer, TClass instance) { WriteObject(writer, value); } - protected void WriteObject(BinaryWriter writer, object t) { + protected void WriteObject(BinaryWriter writer, object obj) { + object t = obj; + + if (obj is Enum && Enum.GetUnderlyingType(obj.GetType()) != Type) { + t = Convert.ChangeType(obj, Type); + } + if (Type == typeof(string)) { writer.WriteNullableString((string)t); } diff --git a/osuElements/IO/Binary/BinaryFileList.cs b/osuElements/IO/Binary/BinaryFileList.cs index 5d0d0f8..89c81bb 100644 --- a/osuElements/IO/Binary/BinaryFileList.cs +++ b/osuElements/IO/Binary/BinaryFileList.cs @@ -53,7 +53,7 @@ public override void ReadValue(BinaryReader binaryReader, ref TClass instance) { } public override void WriteValue(BinaryWriter writer, TClass instance) { - //NYI + throw new NotImplementedException("Binary dictionary writing is not implemented yet."); } } } \ No newline at end of file diff --git a/osuElements/Properties/AssemblyInfo.cs b/osuElements/Properties/AssemblyInfo.cs index 5420308..817ce9a 100644 --- a/osuElements/Properties/AssemblyInfo.cs +++ b/osuElements/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("osuElements")] -[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.7.0")] -[assembly: AssemblyFileVersion("1.0.7.0")] +[assembly: AssemblyVersion("1.0.8.0")] +[assembly: AssemblyFileVersion("1.0.8.0")] diff --git a/osuElements/osuElements.NET.csproj b/osuElements/osuElements.NET.csproj index f6beaaf..edf42c2 100644 --- a/osuElements/osuElements.NET.csproj +++ b/osuElements/osuElements.NET.csproj @@ -47,6 +47,9 @@ + + + diff --git a/osuElements/osuElements.Standard.csproj b/osuElements/osuElements.Standard.csproj index 9d8c20e..2e645c5 100644 --- a/osuElements/osuElements.Standard.csproj +++ b/osuElements/osuElements.Standard.csproj @@ -4,7 +4,14 @@ netstandard1.3 osuElements.Standard osuElements - False + true + 1.0.8 + 1.0.8.0 + osuElements 2021 + an open source osu! framework + osuElements.Standard + osuElements.Standard + osuElements.Standard diff --git a/osuElements/osuElements.cs b/osuElements/osuElements.cs index 4a6e2cb..81b51ff 100644 --- a/osuElements/osuElements.cs +++ b/osuElements/osuElements.cs @@ -1,6 +1,8 @@ -using System.IO; +using System; +using System.IO; using Microsoft.Win32; using osuElements.Api.Repositories; +using osuElements.Api.Throttling; using osuElements.Beatmaps; using osuElements.Db; using osuElements.IO; @@ -24,12 +26,16 @@ static osuElements() { OsuDbRepository = OsuDb.FileReader(); ScoresDbRepository = ScoresDb.FileReader(); - ApiReplayRepository = new ApiReplayRepository(); + // ApiRepositoryThrottler = new TimerThrottler(60, TimeSpan.FromMinutes(1)); + ApiRepositoryThrottler = null; + + ApiMultiplayerRepository = new ApiMultiplayerRepository(); ApiBeatmapRepository = new ApiBeatmapRepository(); ApiReplayRepository = new ApiReplayRepository(); ApiUserRepository = new ApiUserRepository(); ApiScoreRepository = new ApiScoreRepository(); + StreamIOStrategy = new StreamIOStrategy(); #if !STANDARD @@ -79,14 +85,9 @@ public static string OsuDirectory public static IApiUserRepository ApiUserRepository { get; set; } public static IApiMultiplayerRepository ApiMultiplayerRepository { get; set; } public static IApiScoreRepository ApiScoreRepository { get; set; } - public static string ApiKey - { - set { ApiRepositoryBase.Key = value; } - } - public static bool ApiRepositoryThrowExceptions - { - set { ApiRepositoryBase.ThrowExceptions = value; } - } + public static string ApiKey { get; set; } + public static bool ApiRepositoryThrowExceptions { get; set; } = false; + public static IThrottler ApiRepositoryThrottler { get; set; } public static int LatestBeatmapVersion { get; set; } = 14; public static float LatestSkinVersion { get; set; } = 2.5f;