One of the coolest features on Visual Studio 2005 are code snippets
and how easy is to add your personal snippets.
Today Raffaele
Rialdi, one of our MVP, has shared one of its code snippets, created for
building a Singleton class with C#. Just place the following code into the My Documents\Visual Studio 2005\Code Snippets\Visual C#\My
Code Snippets folder and use it on the code window by writing
singleton<tab> on a C# class:
?xml version="1.0" encoding="utf-8"
?>
<CodeSnippets xmlns="http://atd.vevy.com/CodeSnippet">
<CodeSnippet
Format="1.0.0">
<Header>
<Title>singleton</Title>
<Shortcut>singleton</Shortcut>
<Description>Code
snippet for singleton
pattern</Description>
<Author>Raffaele
Rialdi</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[private static
$classname$ _Instance = null;
private $classname$
()
{
}
public static $classname$
GetInstance()
{
if(_Instance ==
null)
_Instance = new
$classname$();
return
_Instance;
}
$end$
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Really useful... 