<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>cprop</Title>
<Shortcut>cprop</Shortcut>
<Description>Code snippet for a CSLA property</Description>
<Author>John Radke</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
<Literal Editable="false">
<ID>classname</ID>
<ToolTip>Class name</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default Value</ToolTip>
<Default>null</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[private static PropertyInfo<$type$> $property$Property =
RegisterProperty(typeof($classname$), new PropertyInfo<$type$>("$property$", $defaultvalue$));
public $type$ $property$
{
get { return GetProperty($property$Property, NoAccessBehavior.ThrowException); }
set { SetProperty<$type$>($property$Property, value); }
}$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
private static PropertyInfo<int> MyPropertyProperty =
RegisterProperty(typeof(Document), new PropertyInfo<int>("MyProperty", null));
public int MyProperty
{
get { return GetProperty(MyPropertyProperty, NoAccessBehavior.ThrowException); }
set { SetProperty<int>(MyPropertyProperty, value); }
}
Refactorings
No refactoring yet !
I'm sure I'm not the first to do this, but here's a Visual Studio Intellisense snippet for CSLA 3.5 properties.
To use, create a file called cprop.snippet in your snippets folder (probably something similar to "C:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033\Visual C#"). Visual Studio should pick it up immediately.