Fredrik Normén's Blog - NSQUARED²
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Microsoft Most Valuable Professional
     .Net Framework - ASP.Net - Architecture - Development
NOTE: This list of posts will only list the 15 latest posts, to see the rest, select from the Archives located in the menu to the left. The RSS will only list the 10 lastest posts.
Configuration sections with attributes.

Category:  ASP.Net 2.0

In my previous post I wrote about how we can create a configuration section. There is an easier way of creating one.
We can create a Configuration section with adding attributes to our properties:

using System.Configuration;
using System.Web.Configuration;

namespace Nsquared2.Web.Configuration
{

   public class MySection: ConfigurationSection
   {

       [ConfigurationProperty("myAttribute", DefaultValue ="myAttribute")]
       public string MyAttribute
       {
           
get { return ((string)base["myAttrbiute"
]); }
           
set { base["myAttribute"
] = value; }
       }
   }
}

This will required less code and will make it easy for us to create our own sections.

 

Posted: Wednesday, April 21, 2004 - 20:17 GMT+1    Print     E-mail    Comments (0)
   fredrik.nsquared2.com - 2007