namespaceSamples.AspNet{publicclassPageAppearanceSection:ConfigurationSection{// Create a "remoteOnly" attribute. [ConfigurationProperty("remoteOnly", DefaultValue = "false", IsRequired = false)]publicBooleanRemoteOnly{get{return(Boolean)this["remoteOnly"];}set{this["remoteOnly"]=value;}}// Create a "font" element. [ConfigurationProperty("font")]publicFontElementFont{get{return(FontElement)this["font"];}set{this["font"]=value;}}...
There’s a much faster way to create normal properties. If you’ve ever used the
prop code snippet to create a property,
you already know this. You can just type “prop” and hit tab to have an entir
property filled out for you:
Faced with the daunting task of creating some custom configuration elements, I
threw together a code snippet that lets you do the same for a
configuration-backed property. I can now just type “propc” and hit tab to get
this:
Then I just fill out the name and type and call it good. If you’d like to join
in on the propc goodness here’s the source of the snippet file. Just download
and save it as a .snippet file and import it through Tools |
Code Snippets Manager in Visual Studio: