// (C) Copyright 2019 C-xC-c // This file is part of BantFlags. // BantFlags is licensed under the GNU AGPL Version 3.0 or later. // see the LICENSE file or using System; namespace BantFlags.Data { public class PoolObject : IDisposable { public T Object { get; } private Action ReturnAction { get; } public PoolObject(T o, Action returnAction) { Object = o; ReturnAction = returnAction; } public void Dispose() { ReturnAction(Object); } public static implicit operator T(PoolObject poolObject) => poolObject.Object; } }