Snippets are a great features in VS 2005. I like using them for getting out codes rather quickly, and having some standard for everyone. I thought it might be useful for everyone to have. I do like the shortcut in VS 2005, with typing in "wpp" and generating the web part property. There are so many web part properties that need to be generated, I like this as a quick way to get them developed.
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>SharePoint Web Part Property</Title>
<Description>Create a SharePoint Web Part Property, Field and Default Field</Description>
<Author>Morgan Everett, 4 QTRS LLC</Author>
<Shortcut>wpp</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Replace with the tyoe of the Web Part Property</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>PropertyName</ID>
<ToolTip>Replace with the Name of the Web Part Property</ToolTip>
<Default>MyWebPartProperty</Default>
</Literal>
<Literal>
<ID>Category</ID>
<ToolTip>Replace with the name of the Category where this property will appear in the ToolPane</ToolTip>
<Default>MyCategory</Default>
</Literal>
<Literal>
<ID>MyFriendlyName</ID>
<ToolTip>Replace with the Friendly Name of the Web Part Property</ToolTip>
<Default>MyFriendlyName</Default>
</Literal>
<Literal>
<ID>MyDescription</ID>
<ToolTip>Replace with the Description of the Web Part Property</ToolTip>
<Default>MyDescription</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[
protected const $type$ default$PropertyName$ = "MyDefault";
protected $type$ m_$PropertyName$ = default$PropertyName$;
[Browsable(true),
Category("$Category$"),
DefaultValue(default$PropertyName$),
WebPartStorage(Storage.Shared),
FriendlyName("$MyFriendlyName$"),
Description("$MyDescription$")]
public $type$ $PropertyName$
{
get
{
return this.m_$PropertyName$;
}
set
{
this.m_$PropertyName$ = value;
}
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Installing
You will need to take this snippet and save it as an xml file, and then install it into My Documents\Visual Studio 2005\Project\Code Snippets, and it should be available in your application as soon as you place the XML.
Morgan