mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Remove Live<> wrapper until it is needed
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -69,31 +68,5 @@ namespace osu.Game.Database
|
||||
|
||||
return mapper.Map<T>(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrap a managed instance of a realm object in a <see cref="Live{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to wrap.</param>
|
||||
/// <param name="contextFactory">A factory to retrieve realm contexts from.</param>
|
||||
/// <typeparam name="T">The type of object.</typeparam>
|
||||
/// <returns>A wrapped instance of the provided item.</returns>
|
||||
public static Live<T> Wrap<T>(this T item, IRealmFactory contextFactory)
|
||||
where T : RealmObject, IHasGuidPrimaryKey => new Live<T>(item, contextFactory);
|
||||
|
||||
/// <summary>
|
||||
/// Wrap an unmanaged instance of a realm object in a <see cref="Live{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to wrap.</param>
|
||||
/// <typeparam name="T">The type of object.</typeparam>
|
||||
/// <returns>A wrapped instance of the provided item.</returns>
|
||||
/// <exception cref="ArgumentException">Throws if the provided item is managed.</exception>
|
||||
public static Live<T> WrapAsUnmanaged<T>(this T item)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
if (item.IsManaged)
|
||||
throw new ArgumentException("Provided item must not be managed", nameof(item));
|
||||
|
||||
return new Live<T>(item, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user