M
mark.milley
Hi all -
Okay, here's a question for all you MVPs out there--I'd like to define
a default implementation for an interface. While I understand that when
you implement a interface, empty routines are created for you (thanks
MS), I'd like to take it one step further and add in comments, and
maybe an If block.
Microsoft does this; for example, implement iDisposable; all of the
code and comments below are created. I'd love to do the same thing. Any
suggestions?
Thanks,
- M
Private disposedValue As Boolean = False ' To detect
redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: free unmanaged resources when explicitly
called
End If
' TODO: free shared unmanaged resources
End If
Me.disposedValue = True
End Sub
#Region " IDisposable Support "
' 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
Okay, here's a question for all you MVPs out there--I'd like to define
a default implementation for an interface. While I understand that when
you implement a interface, empty routines are created for you (thanks
MS), I'd like to take it one step further and add in comments, and
maybe an If block.
Microsoft does this; for example, implement iDisposable; all of the
code and comments below are created. I'd love to do the same thing. Any
suggestions?
Thanks,
- M
Private disposedValue As Boolean = False ' To detect
redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: free unmanaged resources when explicitly
called
End If
' TODO: free shared unmanaged resources
End If
Me.disposedValue = True
End Sub
#Region " IDisposable Support "
' 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