Skip to content

Instantly share code, notes, and snippets.

@jbogard
Created June 9, 2011 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbogard/1016810 to your computer and use it in GitHub Desktop.
Save jbogard/1016810 to your computer and use it in GitHub Desktop.
Disposable Collection
public class DisposableCollection : ReadOnlyCollection<IDisposable>, IDisposable
{
public DisposableCollection(params IDisposable[] list) : base(list)
{
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
foreach (var item in this)
{
item.Dispose();
}
}
}
public void Dispose()
{
Dispose(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment