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

963 Views   
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> <Title>Property with Settings backend</Title> <Author>jerry@nixoncorp.com</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
Tags:
Add a comment


Report Abuse
brought to you by:
West Wind Techologies