using System; namespace Zenject { // Here we assume that each spawned object does the work of returning itself to the pool // in its own Dispose method public class PoolWrapperFactory : IFactory where T : IDisposable { readonly IMemoryPool _pool; public PoolWrapperFactory(IMemoryPool pool) { _pool = pool; } public T Create() { return _pool.Spawn(); } } public class PoolWrapperFactory : IFactory where TValue : IDisposable { readonly IMemoryPool _pool; public PoolWrapperFactory(IMemoryPool pool) { _pool = pool; } public TValue Create(TParam1 arg) { return _pool.Spawn(arg); } } }