Make CreateContext private

This commit is contained in:
Dean Herbert 2022-01-21 16:40:20 +09:00
parent dde10d1ba2
commit a59105635e

View File

@ -72,13 +72,13 @@ namespace osu.Game.Database
get get
{ {
if (!ThreadSafety.IsUpdateThread) if (!ThreadSafety.IsUpdateThread)
throw new InvalidOperationException(@$"Use {nameof(CreateContext)} when performing realm operations from a non-update thread"); throw new InvalidOperationException(@$"Use {nameof(createContext)} when performing realm operations from a non-update thread");
lock (contextLock) lock (contextLock)
{ {
if (context == null) if (context == null)
{ {
context = CreateContext(); context = createContext();
Logger.Log(@$"Opened realm ""{context.Config.DatabasePath}"" at version {context.Config.SchemaVersion}"); Logger.Log(@$"Opened realm ""{context.Config.DatabasePath}"" at version {context.Config.SchemaVersion}");
} }
@ -124,7 +124,7 @@ namespace osu.Game.Database
private void cleanupPendingDeletions() private void cleanupPendingDeletions()
{ {
using (var realm = CreateContext()) using (var realm = createContext())
using (var transaction = realm.BeginWrite()) using (var transaction = realm.BeginWrite())
{ {
var pendingDeleteScores = realm.All<ScoreInfo>().Where(s => s.DeletePending); var pendingDeleteScores = realm.All<ScoreInfo>().Where(s => s.DeletePending);
@ -182,7 +182,7 @@ namespace osu.Game.Database
if (ThreadSafety.IsUpdateThread) if (ThreadSafety.IsUpdateThread)
return action(Context); return action(Context);
using (var realm = CreateContext()) using (var realm = createContext())
return action(realm); return action(realm);
} }
@ -199,12 +199,12 @@ namespace osu.Game.Database
action(Context); action(Context);
else else
{ {
using (var realm = CreateContext()) using (var realm = createContext())
action(realm); action(realm);
} }
} }
public Realm CreateContext() private Realm createContext()
{ {
if (isDisposed) if (isDisposed)
throw new ObjectDisposedException(nameof(RealmContextFactory)); throw new ObjectDisposedException(nameof(RealmContextFactory));