mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Allow "refreshing" instances via DatabaseBackedStore
This commit is contained in:
@ -18,6 +18,11 @@ namespace osu.Game.Database
|
||||
|
||||
private readonly ThreadLocal<OsuDbContext> queryContext;
|
||||
|
||||
/// <summary>
|
||||
/// Refresh an instance potentially from a diffrent thread with a local context-tracked instance.
|
||||
/// </summary>
|
||||
protected void Refresh<T>(ref T obj) where T : class, IHasPrimaryKey => obj = GetContext().Find<T>(obj.ID);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a shared context for performing lookups (or write operations on the update thread, for now).
|
||||
/// </summary>
|
||||
|
10
osu.Game/Database/IHasPrimaryKey.cs
Normal file
10
osu.Game/Database/IHasPrimaryKey.cs
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public interface IHasPrimaryKey
|
||||
{
|
||||
int ID { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user