Created
June 23, 2017 12:13
-
-
Save Regenhardt/ffb3c511ac69bb44305b49616014c2cb to your computer and use it in GitHub Desktop.
C# code snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets | |
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<!-- propnfy --> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Full, notifying Property</Title> | |
<Author>Marlon Regenhardt</Author> | |
<Description>Full property, notifying when changed</Description> | |
<Shortcut>propnfy</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<Default>int</Default> | |
</Literal> | |
<Literal> | |
<ID>privateVar</ID> | |
<Default>myVar</Default> | |
</Literal> | |
<Literal> | |
<ID>publicProperty</ID> | |
<Default>MyProperty</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="CSharp" Kind="method decl"> | |
<![CDATA[ | |
public $type$ $publicProperty$ | |
{ | |
get | |
{ | |
return $privateVar$; | |
} | |
set | |
{ | |
$privateVar$ = value; | |
NotifyPropertyChanged("$publicProperty$"); | |
} | |
} | |
private $type$ $privateVar$;]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
<!-- exp() --> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>exp()</Title> | |
<Author>Marlon Regenhardt</Author> | |
<Shortcut>exp</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>exp</ID> | |
<Default>Method</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="CSharp" Kind="any"> | |
<![CDATA[$exp$($selected$)$end$]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
<!-- cmd --> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Command</Title> | |
<Description>ICommand Property for binding a button</Description> | |
<Shortcut>cmd</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>summary</ID> | |
<Default> | |
Insert summary | |
</Default> | |
</Literal> | |
<Literal> | |
<ID>Name</ID> | |
<Default> | |
SomeCommand | |
</Default> | |
</Literal> | |
<Literal> | |
<ID>field</ID> | |
<Default> | |
_someCommand | |
</Default> | |
</Literal> | |
<Literal> | |
<ID>action</ID> | |
<Default> | |
this.someMethod() | |
</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="CSharp" Kind="method decl"> | |
<![CDATA[ /// <summary> | |
/// $summary$ | |
/// </summary> | |
public ICommand $Name$ | |
{ | |
get | |
{ | |
if (this.$field$ == null) this.$field$ = new RelayCommand(param => $action$$end$); | |
return $field$; | |
} | |
} | |
private RelayCommand $field$;]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
<!-- aaa --> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Triple-A-Pattern</Title> | |
<Author>Marlon Regenhardt</Author> | |
<Description>Triple-A-Pattern for unit testing.</Description> | |
<Shortcut>aaa</Shortcut> | |
</Header> | |
<Snippet> | |
<Code Language="CSharp" Kind="method body"> | |
<![CDATA[ | |
#region [ Arrange ] | |
#endregion | |
#region [ Act ] | |
#endregion | |
#region [ Assert ] | |
#endregion | |
]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
<!-- NUnit test method --> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Test method</Title> | |
<Author>Piotr Perak</Author> | |
<Shortcut>tm</Shortcut> | |
<Description>Shortcut for generating NUnit test method</Description> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>testName</ID> | |
<Default>testName</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="CSharp"> | |
<![CDATA[[Test] | |
public void $testName$() | |
{ | |
$selected$$end$ | |
} | |
]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment