| West Wind Application Settings for .NET |
| Other Configuration Scenarios |
public WebStoreConfig() { this.SetConfigurationSection("wwWebStore"); this.ReadKeysFromConfig(); }
public WebStoreConfig() { // *** Use a custom Config file this.ReadKeysFromConfig(@"d:\projects\wwWebStore\MyConfig.config"); }
Note: If you manually read or write settings in your code make sure you always pass the filename to ReadKeysFromConfig() and WriteKeysFromConfig()!
Note you don't have to implement constructors as I do here. You can simple call the Constructor with false to stop the app from reading the settings from the default location.
For example you can simply do this to instantiate your class:
WebStoreConfig Configuration = new WebStoreConfig(); Configuration.SetEnryption("ConnectionString,MailPassword","EncryptThis"); Configuration.SetConfigurationSection("wwWebStore"); Configuration.ReadKeysFromConfig("wwWebStore.Config");
I simply prefer having a constructor that takes care of this for me so that I don't have to remember what I need to do to get the object instantiated.