I know code snippets have been out there for a while but I haven't had the chance to use them until today. And quite frankly, I should have checked them out before! The default code snippets are interesting (ctor, for, foreach, forr, switch to name a few) but their real power comes from the possibility of adding new ones almost instantly to your work environment.
Here's a code snippet I did for the Singleton Pattern:
|
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Singleton Pattern</Title>
<Shortcut>Singleton</Shortcut>
<Description>Code snippet to define Singleton class</Description>
<Author>marivet</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>Class</ID>
<ToolTip>Type</ToolTip>
<Function>ClassName()</Function>
<Default>SingletonClass</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
#region Singleton Pattern
private $Class$()
{
}
private static $Class$ _instance = null;
public static $Class$ Instance
{
get
{
if (_instance == null)
_instance = new $Class$();
return _instance;
}
}
#endregion
$end$
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
|
Copy this into a .snippet file and put it in your MyDocument/Visual Studio 2005/Code Snippets/Visual C#/My Code Snippets folder and you're ready to go!
Enjoy
b661882c-5e02-4e59-a3c9-45515dfcfee8|0|.0