West Wind Application Settings for .NET |
Class wwAppConfiguration
|
This class provides a Configuration Settings persistance manager. You can use it to store application configuration settings easily simply by creating a subclass with persistance to a configuration file taken care of automatically. It provides the following features:
Values are stored in the AppSettings section of the .Config file by default and uses ApplicationSettings to internally retrieve this data. You can use SetConfigurationSection() to specify a different section in the file. The data is always returned in the proper type format rather than as string and null instances are never a problem as there will always be a default value returned. This reduces the amount of code that goes along with pulling data out of the .Config file.
Supported fields type are any simple types (string, decimal, double, int, boolean, datetime etc. ) as well as enums. Enums are persisted into the front end interface using strings (ie. if you use it in a listbox value the value must be string).
The class also provides the ability to encrypt keys by calling the SetEncryption() method with a list of keys and a password.
Namespace: Westwind.Tools
Inherits: Object
| Member | Description |
|---|---|
ErrorMessage |
Error message that gets set when operations fail. Note not available for any of the static methods that create a new instance of this object. |
GetAllKeysFromConfigSection |
Returns all the keys in the Configuration Section as string key value pairs. Internally uses Configurations class for default configuration and Xml to retrieve in external files. public virtual NameValueCollection GetAllKeysFromConfigSection( string Section, string Filename ); public virtual NameValueCollection GetAllKeysFromConfigSection( string Section ); |
GetKeyFromConfigSection |
Returns a single key from the Configuration Settings Section. public virtual string GetKeyFromConfigSection( string Key, string Section, string Filename ); public virtual string GetKeyFromConfigSection( string Key, |
ReadKeysFromConfig |
Reads all the configuration settings from the .Config file into the public fields of this object. public virtual void ReadKeysFromConfig(); public virtual void ReadKeysFromConfig( string Filename ); public static wwAppConfiguration ReadKeysFromConfig( Type ConfigType ); public static wwAppConfiguration ReadKeysFromConfig( string Filename, |
ReadKeysFromFile |
Reads the configuration settings from an XML file created with WriteKeysToFile public static wwAppConfiguration ReadKeysFromFile( string FileName, Type ConfigurationObjectType ); |
ReadkeysFromSqlServer |
Reads keys from a SQL Database from a table you specify. Table must contain ID (int) and ConfigData fields. public static object ReadkeysFromSqlServer( string ConnectionString, string TableName, int Key, Type ConfigurationObjectType ); |
ReadKeysFromString |
Reads the configuration settings from an XML string created with WriteKeysToString public static wwAppConfiguration ReadKeysFromString( string Xml, Type ConfigurationObjectType ); |
SetConfigurationSection |
Sets the Configuration File Section if the default is section is not used public virtual void SetConfigurationSection( string ConfigurationFileSection ); |
SetEncryption |
Sets the Configuration File Section if the default is section is not used public virtual void SetEncryption( string EncryptFields, string EncryptKey ); |
WriteKeysToConfig |
Writes all of the configuration file properties to the configuration file. public virtual bool WriteKeysToConfig(); public virtual bool WriteKeysToConfig( string Filename ); |
WriteKeysToFile |
Serializes the the current object into a file in XML format on disk public bool WriteKeysToFile( string FileName ); |
WriteKeysToSqlServer |
Writes the Configuration Settings into a SQL Server of your choice table and a field called ConfigData. If the table doesn't exist it's created for you (requires appropriate permissions) public bool WriteKeysToSqlServer( string ConnectionString, string TableName, int Key ); |
WriteKeysToString |
Serializes the current object into a string in XML format public bool WriteKeysToString( ref string XmlResultString ); |