March 3, 2008

Snippet for CRM workflow activity parameter

If you are writing custom workflow activities for workflows in CRM 4.0 you will find this snippet handy.

Copy the code below into a new file and name it CRMParameter.snippet. Save the file into Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets folder. It works in VS2008 too.
The shortcut for the snippet is cwp.

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>CRM workflow property snippet</Title>
<Shortcut>cwp</Shortcut>
<Description>Code snippet for crm property </Description>
<Author>Dejan Dular</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>PropertyInputOutputType</ID>
<ToolTip>Input/output property</ToolTip>
<Default>CrmInput</Default>
</Literal>
<Literal>
<ID>PropertyDisplayName</ID>
<ToolTip>Property display name</ToolTip>
<Default>Display Name</Default>
</Literal>
<Literal>
<ID>PropertyName</ID>
<ToolTip>Property Name</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>Type</ID>
<ToolTip>Property Type</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>Class</ID>
<ToolTip>Class</ToolTip>
<Default>ClassName</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[#region $PropertyDisplayName$
[$PropertyInputOutputType$("$PropertyDisplayName$")]
public $Type$ $PropertyName$
{
get { return ($Type$)base.GetValue($PropertyName$Property); }
set { base.SetValue($PropertyName$Property, value); }
}
public static DependencyProperty $PropertyName$Property = DependencyProperty.Register("$PropertyName$", typeof($Type$), typeof($Class$));
#endregion
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>