CodePaste Logo
New Snippet New Recent Snippets Recent Snippets My Snippets My Snippets My Favorites Favorites Web Code Search Snippets Search
Sign inor Register
Language: xml

propsetting Visual Studio Snippet for Settings-backed properties

<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns=""> <CodeSnippet Format="1.0.0"> <Header> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> <Title>Property with Settings backend</Title> <Author></Author> <Description> </Description> <HelpUrl> </HelpUrl> <Shortcut>propsetting</Shortcut> </Header> <Snippet> <Declarations> <Literal Editable="true"> <ID>name</ID> <ToolTip> </ToolTip> <Default>MyProperty</Default> <Function> </Function> </Literal> <Literal Editable="true"> <ID>type</ID> <ToolTip> </ToolTip> <Default>string</Default> <Function> </Function> </Literal> </Declarations> <Code Language="csharp"><![CDATA[public $type$ $name$ { get { return $name$Setting; } set { $name$Setting = value; RaisePropertyChanged(); } } private static string m_$name$Key = "Setting.$name$"; public static $type$ $name$Setting { get { return StorageHelper.GetSetting<$type$>(m_$name$Key, default($type$)); } set { StorageHelper.SetSetting(m_$name$Key, value); } } ]]></Code> </Snippet> </CodeSnippet> </CodeSnippets>
by Jerry Nixon
  October 05, 2012 @ 1:01pm
Add a comment

Report Abuse
brought to you by:
West Wind Techologies