1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 10:07:36 +08:00
osu-lazer/osu.Game/Configuration/SettingsStore.cs
Dean Herbert a2f1752344 Make settings works with current caching structure
Will likely pull out that `RulesetConfigCache` next, but this is an
"everything works" state.
2021-09-15 16:31:13 +09:00

31 lines
1.0 KiB
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.Collections.Generic;
using System.Linq;
using osu.Game.Database;
namespace osu.Game.Configuration
{
public class SettingsStore
{
private readonly RealmContextFactory realmFactory;
public SettingsStore(RealmContextFactory realmFactory)
{
this.realmFactory = realmFactory;
}
/// <summary>
/// Retrieve <see cref="RealmSetting"/>s for a specified ruleset/variant content.
/// </summary>
/// <param name="rulesetId">The ruleset's internal ID.</param>
/// <param name="variant">An optional variant.</param>
public List<RealmSetting> Query(int? rulesetId = null, int? variant = null)
{
using (var context = realmFactory.GetForRead())
return context.Realm.All<RealmSetting>().Where(b => b.RulesetID == rulesetId && b.Variant == variant).ToList();
}
}
}