My snippets are provided "as is", with no warranty of any kind, either express or implied. Use at your own risk.
Creates the canonical Dispose method override code for types that ultimately derive from the System.ComponentModel.Component class.
Shortcut: disposec
For more information on my C# Code Snippets see my blog entry: Custom C# Code Snippets. All of my snippets may be downloaded at once here.
Usage
This snippet is intended to be used as expansion only from within the body of a class definition. The class must derive, directly or indirectly, from a class with a protected virtual void Dispose(bool disposing) method that is not sealed.
This snippet is useful for classes that derive from System.ComponentModel.Component or derived types such as WinForms Controls. This snippet is not suitable for classes that derive from the ASP.NET Control class.
Example Output
The following code illustrates this snippet's output when it's executed for expansion from within the body of the Person class:
class Person : Component
{
/// <summary>
/// Releases the unmanaged resources used by an instance of the <see cref="Person" /> class
/// and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><strong>true</strong> to release both managed and
/// unmanaged resources; <strong>false</strong> to release only unmanaged resources.</param>
protected override void Dispose(bool disposing)
{
try
{
if (disposing)
{
| {text cursor goes here}
}
}
finally
{
base.Dispose(disposing);
}
}
}