Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8" ?>
- <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
- <CodeSnippet Format="1.0.0">
- <Header>
- <Title>AH DisposePattern</Title>
- <Shortcut>ahDisposePattern</Shortcut>
- <Description>Code snippet created on: 3/9/2010 10:30:58 AM</Description>
- <Author>Andrew Hodgson</Author>
- <SnippetTypes>
- <SnippetType>Expansion</SnippetType>
- </SnippetTypes>
- </Header>
- <Snippet>
- <Declarations>
- <Literal Editable="false">
- <ID>classname</ID>
- <ToolTip>Class name</ToolTip>
- <Function>ClassName()</Function>
- <Default>ClassNamePlaceholder</Default>
- </Literal>
- </Declarations>
- <Code Language="csharp">
- <![CDATA[#region IDisposable
- protected bool IsDisposed { get; private set; }
- public virtual void Dispose() {
- if(IsDisposed)
- throw new ObjectDisposedException(this.GetType().Name);
- try {
- this.Dispose(true);
- }
- finally {
- GC.SuppressFinalize(this);
- }
- }
- protected virtual void Dispose(bool disposing) {
- try {
- if(!IsDisposed) {
- if(disposing) {
- $end$
- }
- }
- }
- finally {
- this.IsDisposed = true;
- }
- }
- #endregion]]>
- </Code>
- </Snippet>
- </CodeSnippet>
- </CodeSnippets>
Advertisement
Add Comment
Please, Sign In to add comment