Clone this repository to:
%USERPROFILE%\Documents\Visual Studio 2015\Code Snippets\Visual C#\My 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>Method template</Title> | |
| <Shortcut>method</Shortcut> | |
| <Description>New method template</Description> | |
| <Author>Philipp Munin</Author> | |
| <SnippetTypes> | |
| <SnippetType>Expansion</SnippetType> | |
| </SnippetTypes> | |
| </Header> | |
| <Snippet> | |
| <Declarations> | |
| <Literal Editable="true"> | |
| <ID>returnType</ID> | |
| <Default>void</Default> | |
| </Literal> | |
| <Literal Editable="true"> | |
| <ID>visibility</ID> | |
| <Default>public</Default> | |
| </Literal> | |
| <Literal Editable="true"> | |
| <ID>methodName</ID> | |
| <Default>MyMethod</Default> | |
| </Literal> | |
| <Literal Editable="true"> | |
| <ID>params</ID> | |
| <Default>object state</Default> | |
| </Literal> | |
| <Literal Editable="false"> | |
| <ID>exception</ID> | |
| <Function>SimpleTypeName(global::System.NotImplementedException)</Function> | |
| </Literal> | |
| <Literal> | |
| <ID>Body</ID> | |
| <Default>throw new NotImplementedException();</Default> | |
| </Literal> | |
| </Declarations> | |
| <Code Language="csharp"> | |
| <![CDATA[$visibility$ $returnType$ $methodName$($params$) | |
| { | |
| $end$$Body$ | |
| }]]> | |
| </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>throw Not Implemented Exception</Title> | |
| <Shortcut>tni</Shortcut> | |
| <Description>throw NotImplementedException</Description> | |
| <Author>Philipp Munin</Author> | |
| <SnippetTypes> | |
| <SnippetType>Expansion</SnippetType> | |
| </SnippetTypes> | |
| </Header> | |
| <Snippet> | |
| <Declarations> | |
| <Literal> | |
| <ID>string</ID> | |
| <ToolTip>Exception message</ToolTip> | |
| <Default></Default> | |
| </Literal> | |
| <Literal Editable="false"> | |
| <ID>SystemNotImplementedException</ID> | |
| <Function>SimpleTypeName(global::System.NotImplementedException)</Function> | |
| </Literal> | |
| </Declarations> | |
| <Code Language="csharp"><![CDATA[throw new $SystemNotImplementedException$($string$);$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>propfulln</Title> | |
| <Shortcut>propfulln</Shortcut> | |
| <Description>Code snippet for property and backing field, with OnPropertyChanged notification</Description> | |
| <Author>PMunin</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> | |
| <ID>field</ID> | |
| <ToolTip>The variable backing this property</ToolTip> | |
| <Default>myVar</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>parameters</ID> | |
| <ToolTip>Constructor Parameters</ToolTip> | |
| <Default>calculate()</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>description</ID> | |
| <ToolTip>Description</ToolTip> | |
| <Default>Short description</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>defaultValue</ID> | |
| <ToolTip>Default value indicating that need to initialize</ToolTip> | |
| <Default>null</Default> | |
| </Literal> | |
| </Declarations> | |
| <Code Language="csharp"> | |
| <![CDATA[#region $property$ $description$ | |
| private $type$ $field$ = $defaultValue$; | |
| ///<summary> | |
| /// $description$$end$ | |
| ///</summary> | |
| public $type$ $property$ | |
| { | |
| get { return $field$;} | |
| set | |
| { | |
| if($field$ == value) return; | |
| $field$ = value; | |
| OnPropertyChanged(nameof($property$)); | |
| } | |
| } | |
| #endregion $property$]]> | |
| </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>propInitOnGet</Title> | |
| <Shortcut>propInitOnGet</Shortcut> | |
| <Description>Code snippet for property and backing field that being constructed on first call</Description> | |
| <Author>PMunin</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> | |
| <ID>field</ID> | |
| <ToolTip>The variable backing this property</ToolTip> | |
| <Default>myVar</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>description</ID> | |
| <ToolTip>Description</ToolTip> | |
| <Default>initialized on first get</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>defaultValue</ID> | |
| <ToolTip>Default value indicating that need to initialize</ToolTip> | |
| <Default>null</Default> | |
| </Literal> | |
| </Declarations> | |
| <Code Language="csharp"> | |
| <![CDATA[#region $property$ $description$ | |
| private $type$ $field$ = $defaultValue$; | |
| ///<summary> | |
| /// $description$ | |
| ///</summary> | |
| public $type$ $property$ | |
| { | |
| get { | |
| if($field$ == $defaultValue$) | |
| { | |
| $field$ = new $type$($end$); | |
| } | |
| return $field$; | |
| } | |
| } | |
| #endregion $property$]]> | |
| </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>propLazy</Title> | |
| <Shortcut>propLazy</Shortcut> | |
| <Description>Code snippet for property and backing field that being constructed on first get</Description> | |
| <Author>PMunin</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> | |
| <ID>field</ID> | |
| <ToolTip>The variable backing this property</ToolTip> | |
| <Default>myProperty</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>parameters</ID> | |
| <ToolTip>Constructor Parameters</ToolTip> | |
| <Default>calculate()</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>description</ID> | |
| <ToolTip>Description</ToolTip> | |
| <Default>initialized Lazy on first get</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>defaultValue</ID> | |
| <ToolTip>Default value indicating that need to initialize</ToolTip> | |
| <Default>null</Default> | |
| </Literal> | |
| </Declarations> | |
| <Code Language="csharp"> | |
| <![CDATA[#region $property$ $description$ | |
| private Lazy<$type$> $field$; | |
| ///<summary> | |
| /// $description$ | |
| ///</summary> | |
| public $type$ $property$ | |
| { | |
| get { | |
| if($field$ == null) | |
| $field$ = new Lazy<$type$>(()=>{ | |
| return $parameters$; $end$ | |
| }); | |
| return $field$.Value; | |
| } | |
| } | |
| #endregion $property$]]> | |
| </Code> | |
| </Snippet> | |
| </CodeSnippet> | |
| </CodeSnippets> |