Class AppConfiguration

This class provides a base class for code-first, strongly typed configuration settings in .NET. It supports storing of configuration data in .NET .config files, plain XML files, strings and SQL Server databases and custom providers.

Using this class is easy: Create a subclass of AppConfiguration and then simply add properties to the class. Then instantiate the class, call Initialize(), then simply access the class properties to read configuration values.

The default implementation uses standard .NET configuration files and a custom section within that file to hold configuration values. Other providers can be used to store data to different stores and you can create your own custom providers to store configuration data in yet other stores.

System.Object
  Westwind.Utilities.Configuration.AppConfiguration
public abstract class AppConfiguration : object

Class Members

MemberDescription

Constructor

Default constructor of this class SHOULD ALWAYS be implemented in every subclass to allow serialization instantiation and setting of initial property values.

ErrorMessage

Contains an error message if a method returns false or the object fails to load the configuration data.

Provider

An instance of a IConfigurationProvider that needs to be passed in via constructor or set explicitly to read and write from the configuration store.

Initialize

This method initializes the configuration object with a provider and performs an initial read from the config store.

public void Initialize(IConfigurationProvider provider,     string sectionName,     object configData)

Read

Reads the configuration from the provider's store into the current object instance.

public virtual bool Read()

public virtual bool Read(string xml)

Read

Reads the configuration information from the provider's store and returns a new instance of an configuration object.

public virtual T Read()

public static T Read(IConfigurationProvider provider)

public static T Read(string xml,     IConfigurationProvider provider)

public static T Read(string xml)

Write

Writes the current configuration information data to the provider's configuration store.

public virtual bool Write()

WriteAsString

Writes the current configuration information to an XML string. String is in .NET XML Serialization format.

public virtual string WriteAsString()

Requirements

Namespace: Westwind.Utilities.Configuration
Assembly: westwind.utilities.dll

See also:

Managing Configuration Settings with AppConfiguration

© West Wind Technologies, 2019 • Updated: 06/23/19
Comment or report problem with topic