Skip to content

Instantly share code, notes, and snippets.

@Xiaoy312
Created January 8, 2016 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xiaoy312/04c411accad8689f4e17 to your computer and use it in GitHub Desktop.
Save Xiaoy312/04c411accad8689f4e17 to your computer and use it in GitHub Desktop.
Visual C# Code Snippets
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a DependencyProperty</Title>
<Shortcut>dpprop</Shortcut>
<Description>Dependency Property</Description>
<Author>Xiaoy312</Author>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>propertyType</ID>
<ToolTip>Property type</ToolTip>
<Default>object</Default>
</Literal>
<Literal>
<ID>propertyName</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
<Literal Editable="false">
<ID>className</ID>
<ToolTip>Class name</ToolTip>
<Function>ClassName()</Function>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[$propertyType$ $propertyName$; //hack: Press Ctrl+L to remove this
#region DependencyProperty<$propertyType$> $propertyName$Property
public static readonly DependencyProperty $propertyName$Property =
DependencyProperty.Register("$propertyName$", typeof($propertyType$), typeof($className$),
new PropertyMetadata(default($propertyType$)));
public $propertyType$ $propertyName$
{
get { return ($propertyType$)GetValue($propertyName$Property); }
set { SetValue($propertyName$Property, value); }
}
#endregion
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a RxIU Property</Title>
<Shortcut>rxprop</Shortcut>
<Description>RxIU Property</Description>
<Author>Xiaoy312</Author>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>object</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[$type$ $property$; //hack: Press Ctrl+L to remove this
#region public $type$ $property$
private $type$ m_$property$;
public $type$ $property$
{
get { return m_$property$; }
set { this.RaiseAndSetIfChanged(ref m_$property$, value); }
}
#endregion
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment