If I have a class which makes use of managed resources only, so I don't see any need to fully implement the IDisposable pattern.
Surely this is sufficient:
public class ManagedResourceClient : IDisposable
{
private ITheManagedResource _myManagedResource = new TheManagedResource()
public void Dispose()
{
if ( _myManagedResource != null )
{
_myManagedResource.Dispose();
_myManagedResource = null;
}
}
}
I don't see any reason to use:
- a finalizer as this is using only managed resources that implement IDisposable
- a 'disposing' flag as this is handled by a null check
- a virtual Disposing method as there is no need to differentiate between GC calls and direct calls.
Can the above be confirmed as correct?