Skip to content

Instantly share code, notes, and snippets.

@Sebazzz
Created August 24, 2012 18:18
Show Gist options
  • Save Sebazzz/3453874 to your computer and use it in GitHub Desktop.
Save Sebazzz/3453874 to your computer and use it in GitHub Desktop.
Disposable Pattern
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Shortcut/@EntryValue">DisposablePattern</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Description/@EntryValue">Skeleton implementation for Disposable pattern</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Text/@EntryValue">private bool disposed;&#xD;
&#xD;
/// &lt;summary&gt;&#xD;
/// Releases unmanaged resources and performs other cleanup operations before the&#xD;
/// &lt;see cref="$ClassName$"/&gt; is reclaimed by garbage collection.&#xD;
/// &lt;/summary&gt;&#xD;
~$ClassName$() {&#xD;
this.Dispose(false);&#xD;
}&#xD;
&#xD;
/// &lt;summary&gt;&#xD;
/// Releases unmanaged and - optionally - managed resources&#xD;
/// &lt;/summary&gt;&#xD;
/// &lt;param name="disposing"&gt;&lt;c&gt;true&lt;/c&gt; to release both managed and unmanaged resources; &lt;c&gt;false&lt;/c&gt; to release only unmanaged resources.&lt;/param&gt;&#xD;
protected virtual void Dispose(bool disposing) {&#xD;
if (!disposed) {&#xD;
if (disposing) {&#xD;
// TODO: release managed resources&#xD;
}&#xD;
&#xD;
// TODO: release unmanaged resources&#xD;
&#xD;
this.disposed = true;&#xD;
}&#xD;
}&#xD;
&#xD;
/// &lt;summary&gt;&#xD;
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.&#xD;
/// &lt;/summary&gt;&#xD;
public void Dispose() {&#xD;
this.Dispose(true);&#xD;
&#xD;
GC.SuppressFinalize(this);&#xD;
}</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Reformat/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/ShortenQualifiedReferences/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Applicability/=Live/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/Type/@EntryValue">InCSharpTypeMember</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue">2.0</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Field/=ClassName/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Field/=ClassName/Expression/@EntryValue">typeName()</s:String>
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Field/=ClassName/InitialRange/@EntryValue">-1</s:Int64>
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8E61C859EB76F74A941E057B7CA12454/Field/=ClassName/Order/@EntryValue">0</s:Int64></wpf:ResourceDictionary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment