ConfigurationSection alternatives (.NET 4.5.1)

Is there a better and cleaner way to create config files as opposed to using ConfigurationSection? Below is the code which is very wrong to enter wrong names as well as dirty and ugly code. now it is generally okay if you have few configurations but I have over 100 and this code becomes a nightmare and very ugly.

Below is the code I have.

    [ConfigurationProperty("gridPageSize", DefaultValue = 10)]
    [IntegerValidator(MinValue = 1, MaxValue = 100)]
    public int GridPageSize
    {
        get { return (int)this["gridPageSize"]; }
        set { this["gridPageSize"] = value; }
    }

      

UPDATED At least I would like to read the "gridPageSize" line from the resource file, while this works for get; set, it doesn't work for ConfigurationPropertyAttribute

+3


source to share


1 answer


You can consider West Wind Application Configuration for .NET . Rick's design is cleaner and still flexible.



Even for Microsoft, the old configuration design is too complex. The IIS team uses XML schema files to replace such hard-coded sections for IIS 7 and above, which is an alternative way. However, this piece of code is not sad with sadness.

+1


source







All Articles