Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Ever wanted to write some quick properties that cache the base properties?
- // This should make your life a tad easier :P
- // Modify as you wish
- <?xml version="1.0" encoding="utf-8" ?>
- <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
- <CodeSnippet Format="1.0.0">
- <Header>
- <Title>propcache</Title>
- <Shortcut>propcache</Shortcut>
- <Description>Code snippet for a cached property and backing field</Description>
- <Author>Microsoft Corporation</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>
- </Declarations>
- <Code Language="csharp">
- <![CDATA[
- private $type$ _$field$;
- public $type$ $field$
- {
- get { return _$field$ ?? (_$field$ = base.$field$);}
- }
- $end$]]>
- </Code>
- </Snippet>
- </CodeSnippet>
- </CodeSnippets>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement