Created
June 9, 2011 14:15
-
-
Save jbogard/1016810 to your computer and use it in GitHub Desktop.
Disposable Collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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