mirror of https://github.com/ppy/osu
Add helper method for detaching lists from realm
This commit is contained in:
parent
d810af82ec
commit
fc55d67c66
|
@ -1,6 +1,7 @@
|
|||
// 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 AutoMapper;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
|
@ -39,6 +40,16 @@ public static class RealmExtensions
|
|||
c.CreateMap<RulesetInfo, RulesetInfo>();
|
||||
}).CreateMapper();
|
||||
|
||||
public static List<T> Detach<T>(this List<T> items) where T : RealmObject
|
||||
{
|
||||
var list = new List<T>();
|
||||
|
||||
foreach (var obj in items)
|
||||
list.Add(obj.Detach());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static T Detach<T>(this T obj) where T : RealmObject
|
||||
{
|
||||
if (!obj.IsManaged)
|
||||
|
|
Loading…
Reference in New Issue