Language: XML
propsetting Visual Studio Snippet for Settings-backed properties
<?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@online.jerrynixon.com</Author> <Description> </Description> <HelpUrl> </HelpUrl> <Shortcut>propsetting</Shortcut> </Header> <Snippet> <Declarations> <Literal> <ID>name</ID> <Default>MyProperty</Default> </Literal> <Literal> <ID>type</ID> <Default>string</Default> </Literal> </Declarations> <Code Language="CSharp"> <![CDATA[string m_$name$Name = "$name$"; $type$ m_$name$Default = default($type$); public $type$ $name$ { get { try { return ($type$)Windows.Storage.ApplicationData.Current.LocalSettings.Values[m_$name$Name]; } catch { return m_$name$Default; } } set { Windows.Storage.ApplicationData.Current.LocalSettings.Values[m_$name$Name] = value; Windows.Storage.ApplicationData.Current.SignalDataChanged(); if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(m_$name$Name)); } } ]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
Tags:
Report Abuse
Subscribe
Discuss
News
About
New Snippet
Recent Snippets
My Snippets
Favorites
Web Code
Search
Copy
Line#