Disposable Registry: good pattern?
- by illdev
Imagine a:
public class Global : IDisposable
{
private static readonly List<IDisposable> Disposables = new List<IDisposable>();
public void ApplicationStart()
{
var heavyLifter = new HeavyLifter();
Disposables.Add(heavyLifter);
}
public void Dispose()
{
Disposables.ForEach(d => d.Dispose());
}
}
I am somewhat inexperienced with IDisposable. Is this a viable pattern?