When creating a new class in .Net if I declare it "Implements IDisposable" and hit enter, I see that Visual Studio adds by itselt differents methods and functions already filled to my class. When I try to do so with my Interfaces, it creates empty methods and functions.
Is there any way to provide a default implementations of my methods and functions ?
I have been looking to Link but it didn't resolve my issue.
Example of implementation I'm looking for :
#Region "IDisposable Support"
Private disposedValue As Boolean ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).
End If
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' TODO: override Finalize() only if Dispose(ByVal disposing As Boolean) above has code to free unmanaged resources.
'Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
' Dispose(False)
' MyBase.Finalize()
'End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
Cheers in advance.
Further exaplanations of what I'm looking for :
Let's assume the following Interface
Here is what happens and what I'm looking for :