1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

Add ability to construct RealmLive from ID

This commit is contained in:
Dean Herbert 2023-08-16 14:23:01 +09:00
parent 2a3f7e7362
commit 502844a858

View File

@ -30,7 +30,7 @@ namespace osu.Game.Database
/// <summary>
/// Construct a new instance of live realm data.
/// </summary>
/// <param name="data">The realm data.</param>
/// <param name="data">The realm data. Must be managed (see <see cref="IRealmObject.IsManaged"/>).</param>
/// <param name="realm">The realm factory the data was sourced from. May be null for an unmanaged object.</param>
public RealmLive(T data, RealmAccess realm)
: base(data.ID)
@ -41,6 +41,24 @@ namespace osu.Game.Database
dataIsFromUpdateThread = ThreadSafety.IsUpdateThread;
}
/// <summary>
/// Construct a new instance of live realm data from an ID.
/// </summary>
/// <param name="id">The ID of an already-persisting realm instance.</param>
/// <param name="realm">The realm factory the data was sourced from. May be null for an unmanaged object.</param>
public RealmLive(Guid id, RealmAccess realm)
: base(id)
{
data = retrieveFromID(realm.Realm);
if (data.IsNull())
throw new ArgumentException("Realm instance for provided ID could not be found.", nameof(id));
this.realm = realm;
dataIsFromUpdateThread = ThreadSafety.IsUpdateThread;
}
/// <summary>
/// Perform a read operation on this live object.
/// </summary>