System.Configuration.SettingsProvider Class

Acts as a base class for deriving custom settings providers in the application settings architecture.

See Also: SettingsProvider Members

Syntax

public abstract class SettingsProvider : System.Configuration.Provider.ProviderBase

Remarks

A settings provider defines the mechanism for storing configuration data used in the application settings architecture. The .NET Framework contains a single default settings provider, System.Configuration.LocalFileSettingsProvider, which stores configuration data to the local file system. However, you can create alternate storage mechanisms by deriving from the abstract System.Configuration.SettingsProvider class. The provider that a wrapper class uses is determined by decorating the wrapper class with the System.Configuration.SettingsProviderAttribute. If this attribute is not provided, the default, System.Configuration.LocalFileSettingsProvider, is used.

When you create a custom settings provider, at minimum, you must provide implementations for the three methods of this class: SettingsProvider.GetPropertyValues(SettingsContext, SettingsPropertyCollection), SettingsProvider.SetPropertyValues(SettingsContext, SettingsPropertyValueCollection) and SettingsProvider.ApplicationName.

For client applications, you can add more standardized functionality to a custom provider by also implementing the System.Configuration.IApplicationSettingsProvider interface. This interface mirrors methods found in the System.Configuration.ApplicationSettingsBase class, which mainly enables versioning support.

Typically, you should design settings providers to be single-instanced to avoid storage resource contention. Providers should also be thread-safe because they can be called simultaneously from multiple wrapper instances in a single application domain or from multiple applications in different domains.

At minimum, a settings provider must recognize three attributes—System.Configuration.ApplicationScopedSettingAttribute, System.Configuration.UserScopedSettingAttribute, and System.Configuration.DefaultSettingValueAttribute. For a full listing of attributes that can be applied to application settings, see Application Settings Attributes. A custom setting provider should resolve attributes applied to settings properties in the following manner:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

Requirements

Namespace: System.Configuration
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0