public Task <int> GetAvailableCount(StableStorage stableStorage) => Task.Run(() => GetStableImportPaths(PrepareStableStorage(stableStorage)).Count());
protected override Storage PrepareStableStorage(StableStorage stableStorage) => stableStorage.GetSongStorage();
private void load(LadderInfo ladder, GameHost host) { StableStorage stable; try { stable = new StableStorage(host as DesktopGameHost); } catch (Exception e) { Logger.Error(e, "Stable installation could not be found; disabling file based IPC"); return; } const string file_ipc_filename = "ipc.txt"; const string file_ipc_state_filename = "ipc-state.txt"; const string file_ipc_scores_filename = "ipc-scores.txt"; const string file_ipc_channel_filename = "ipc-channel.txt"; if (stable.Exists(file_ipc_filename)) { Scheduler.AddDelayed(delegate { try { using (var stream = stable.GetStream(file_ipc_filename)) using (var sr = new StreamReader(stream)) { var beatmapId = int.Parse(sr.ReadLine()); var mods = int.Parse(sr.ReadLine()); if (lastBeatmapId != beatmapId) { lastBeatmapId = beatmapId; var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.BeatmapInfo != null); if (existing != null) { Beatmap.Value = existing.BeatmapInfo; } else { var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId }); req.Success += b => Beatmap.Value = b.ToBeatmap(Rulesets); API.Queue(req); } } Mods.Value = (LegacyMods)mods; } } catch { // file might be in use. } try { using (var stream = stable.GetStream(file_ipc_channel_filename)) using (var sr = new StreamReader(stream)) { ChatChannel.Value = sr.ReadLine(); } } catch (Exception) { // file might be in use. } try { using (var stream = stable.GetStream(file_ipc_state_filename)) using (var sr = new StreamReader(stream)) { State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine()); } } catch (Exception) { // file might be in use. } try { using (var stream = stable.GetStream(file_ipc_scores_filename)) using (var sr = new StreamReader(stream)) { Score1.Value = int.Parse(sr.ReadLine()); Score2.Value = int.Parse(sr.ReadLine()); } } catch (Exception) { // file might be in use. } }, 250, true); } }
/// <summary> /// Run any required traversal operations on the stable storage location before performing operations. /// </summary> /// <param name="stableStorage">The stable storage.</param> /// <returns>The usable storage. Return the unchanged <paramref name="stableStorage"/> if no traversal is required.</returns> protected virtual Storage PrepareStableStorage(StableStorage stableStorage) => stableStorage;
public Task ImportFromStableAsync(StableStorage stableStorage) { return(scoreModelManager.ImportFromStableAsync(stableStorage)); }