Created
November 30, 2011 21:02
-
-
Save rohansingh/1410807 to your computer and use it in GitHub Desktop.
ConfigProperty snippet for C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Shortcut>propc</Shortcut> | |
<Title>propc</Title> | |
<Author>Rohan Singh</Author> | |
<Description> | |
Code snippet for a configuration-backed property | |
</Description> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<ToolTip>Property type</ToolTip> | |
<Default>string</Default> | |
</Literal> | |
<Literal> | |
<ID>configurationProperty</ID> | |
<ToolTip>Configuration property name</ToolTip> | |
<Default>myProperty</Default> | |
</Literal> | |
<Literal> | |
<ID>isRequired</ID> | |
<ToolTip>Specifies whether the property is required</ToolTip> | |
<Default>true</Default> | |
<Type>System.Boolean</Type> | |
</Literal> | |
<Literal> | |
<ID>property</ID> | |
<ToolTip>Property name</ToolTip> | |
<Default>MyProperty</Default> | |
</Literal> | |
<Literal Editable="false"> | |
<ID>SystemConfigurationConfigurationProperty</ID> | |
<Function>SimpleTypeName(global::System.Configuration.ConfigurationProperty)</Function> | |
</Literal> | |
</Declarations> | |
<Code Language="CSharp"><![CDATA[[$SystemConfigurationConfigurationProperty$("$configurationProperty$", IsRequired = $isRequired$)] | |
public $type$ $property$ | |
{ | |
get | |
{ | |
return ($type$)this["$configurationProperty$"]; | |
} | |
set | |
{ | |
this["$configurationProperty$"] = value; | |
} | |
} | |
$end$]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment