2021-09-30 10:33:12 +00:00
|
|
|
// 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;
|
|
|
|
|
2021-11-26 05:38:39 +00:00
|
|
|
#nullable enable
|
|
|
|
|
2021-09-30 10:33:12 +00:00
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
|
|
|
public class EntityFrameworkLive<T> : ILive<T> where T : class
|
|
|
|
{
|
|
|
|
public EntityFrameworkLive(T item)
|
|
|
|
{
|
2021-11-26 05:39:35 +00:00
|
|
|
IsManaged = true; // no way to really know.
|
2021-09-30 10:33:12 +00:00
|
|
|
Value = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Guid ID => throw new InvalidOperationException();
|
|
|
|
|
|
|
|
public void PerformRead(Action<T> perform)
|
|
|
|
{
|
|
|
|
perform(Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public TReturn PerformRead<TReturn>(Func<T, TReturn> perform)
|
|
|
|
{
|
|
|
|
return perform(Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PerformWrite(Action<T> perform)
|
|
|
|
{
|
|
|
|
perform(Value);
|
|
|
|
}
|
|
|
|
|
2021-11-26 05:39:35 +00:00
|
|
|
public bool IsManaged { get; }
|
|
|
|
|
2021-09-30 10:33:12 +00:00
|
|
|
public T Value { get; }
|
2021-11-26 05:38:39 +00:00
|
|
|
|
|
|
|
public bool Equals(ILive<T>? other) => ID == other?.ID;
|
2021-09-30 10:33:12 +00:00
|
|
|
}
|
|
|
|
}
|