IDisposable Pattern best practices question
I've spent the morning working on series of resource leak problems. After ensuring that our production code and the unit tests call dispose, I'm left with an interesting question. How far should I propogate IDisposable through my containment heirarchy? Suppose I have class Foo that contains an image:
class Foo : IDisposable {
private Image image
...
pubic void Dispose(bool disposing) {
...
image.Dispose()
}
Should the class Foobar that contains Foo also implement Dispose? So that Foo.Dispose() has chance of being called, without waiting for the GC? How far should IDisposable ripple through the code?
Time for a nice cup of tea - maybe that will help clarify my thinking.