Skip to content

Instantly share code, notes, and snippets.

@tomeko
Created March 12, 2020 22:44
Show Gist options
  • Save tomeko/60cd46afc130f2bac54cc2b8c5041d29 to your computer and use it in GitHub Desktop.
Save tomeko/60cd46afc130f2bac54cc2b8c5041d29 to your computer and use it in GitHub Desktop.
VS C# Snippets
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Debug Writeline</Title>
<Description>Inserts debug writeline with interp. string</Description>
<Shortcut>dline</Shortcut>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[Debug.WriteLine($$"$String$");]]>
</Code>
<Declarations>
<Literal>
<ID>String</ID>
<ToolTip>insert string</ToolTip>
<Default>debug</Default>
</Literal>
</Declarations>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>INotify Property Changed Method</Title>
<Author>tomeko</Author>
<Shortcut>inotify</Shortcut>
<Description>NotifyPropertyChanged method and binds to the event handler</Description>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
]]>
</Code>
</Snippet>
</CodeSnippet>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Notifiable Property</Title>
<Author>tomeko</Author>
<Shortcut>iprop</Shortcut>
<Description>Property Changed</Description>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>Type</ID>
<Default>string</Default>
</Literal>
<Literal>
<ID>Property</ID>
<Default>PlaceHolder</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[private $Type$ _$Property$;
public $Type$ $Property$ { get { return _$Property$; } set { _$Property$ = value; NotifyPropertyChanged(); } }]]>
</Code>
</Snippet>
</CodeSnippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment