Merge pull request #15850 from peppy/realm-integration/misc-qol

Apply a couple of realm related documentation/interface changes
This commit is contained in:
Dan Balasescu 2021-11-29 18:58:15 +09:00 committed by GitHub
commit 8a188b74b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -67,7 +67,7 @@ namespace osu.Game.Tests.Database
{ {
RunTestWithRealm((realmFactory, _) => RunTestWithRealm((realmFactory, _) =>
{ {
RealmLive<RealmBeatmap>? liveBeatmap = null; ILive<RealmBeatmap>? liveBeatmap = null;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
using (var threadContext = realmFactory.CreateContext()) using (var threadContext = realmFactory.CreateContext())
@ -104,7 +104,7 @@ namespace osu.Game.Tests.Database
{ {
RunTestWithRealm((realmFactory, _) => RunTestWithRealm((realmFactory, _) =>
{ {
RealmLive<RealmBeatmap>? liveBeatmap = null; ILive<RealmBeatmap>? liveBeatmap = null;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
using (var threadContext = realmFactory.CreateContext()) using (var threadContext = realmFactory.CreateContext())
@ -133,7 +133,7 @@ namespace osu.Game.Tests.Database
{ {
RunTestWithRealm((realmFactory, _) => RunTestWithRealm((realmFactory, _) =>
{ {
RealmLive<RealmBeatmap>? liveBeatmap = null; ILive<RealmBeatmap>? liveBeatmap = null;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
using (var threadContext = realmFactory.CreateContext()) using (var threadContext = realmFactory.CreateContext())
@ -159,7 +159,7 @@ namespace osu.Game.Tests.Database
{ {
RunTestWithRealm((realmFactory, _) => RunTestWithRealm((realmFactory, _) =>
{ {
RealmLive<RealmBeatmap>? liveBeatmap = null; ILive<RealmBeatmap>? liveBeatmap = null;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
using (var threadContext = realmFactory.CreateContext()) using (var threadContext = realmFactory.CreateContext())
@ -192,7 +192,7 @@ namespace osu.Game.Tests.Database
using (var updateThreadContext = realmFactory.CreateContext()) using (var updateThreadContext = realmFactory.CreateContext())
{ {
updateThreadContext.All<RealmBeatmap>().SubscribeForNotifications(gotChange); updateThreadContext.All<RealmBeatmap>().SubscribeForNotifications(gotChange);
RealmLive<RealmBeatmap>? liveBeatmap = null; ILive<RealmBeatmap>? liveBeatmap = null;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {

View File

@ -49,13 +49,13 @@ namespace osu.Game.Database
return mapper.Map<T>(item); return mapper.Map<T>(item);
} }
public static List<RealmLive<T>> ToLive<T>(this IEnumerable<T> realmList) public static List<ILive<T>> ToLive<T>(this IEnumerable<T> realmList)
where T : RealmObject, IHasGuidPrimaryKey where T : RealmObject, IHasGuidPrimaryKey
{ {
return realmList.Select(l => new RealmLive<T>(l)).ToList(); return realmList.Select(l => new RealmLive<T>(l)).Cast<ILive<T>>().ToList();
} }
public static RealmLive<T> ToLive<T>(this T realmObject) public static ILive<T> ToLive<T>(this T realmObject)
where T : RealmObject, IHasGuidPrimaryKey where T : RealmObject, IHasGuidPrimaryKey
{ {
return new RealmLive<T>(realmObject); return new RealmLive<T>(realmObject);

View File

@ -16,6 +16,7 @@ namespace osu.Game.Models
{ {
public RealmFile File { get; set; } = null!; public RealmFile File { get; set; } = null!;
// [Indexed] cannot be used on `EmbeddedObject`s as it only applies to top-level queries. May need to reconsider this if performance becomes a concern.
public string Filename { get; set; } = null!; public string Filename { get; set; } = null!;
public RealmNamedFileUsage(RealmFile file, string filename) public RealmNamedFileUsage(RealmFile file, string filename)