SettingsProvider Class

Definition

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

public ref class SettingsProvider abstract : System::Configuration::Provider::ProviderBase
public abstract class SettingsProvider : System.Configuration.Provider.ProviderBase
type SettingsProvider = class
    inherit ProviderBase
Public MustInherit Class SettingsProvider
Inherits ProviderBase
Inheritance
SettingsProvider
Derived

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, LocalFileSettingsProvider, which stores configuration data to the local file system. However, you can create alternate storage mechanisms by deriving from the abstract SettingsProvider class. The provider that a wrapper class uses is determined by decorating the wrapper class with the SettingsProviderAttribute. If this attribute is not provided, the default, LocalFileSettingsProvider, is used.

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

For client applications, you can add more standardized functionality to a custom provider by also implementing the IApplicationSettingsProvider interface. This interface mirrors methods found in the 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 - ApplicationScopedSettingAttribute, UserScopedSettingAttribute, and 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:

  1. If the provider can fulfill the request implied by the attribute, obviously it should do so.

  2. If the provider cannot fulfill the request, it should ignore it silently.

  3. If two or more properties conflict; for example, a property being decorated with both ApplicationScopedSettingAttribute and UserScopedSettingAttribute; the provider should throw a ConfigurationException.

Constructors

SettingsProvider()

Initializes an instance of the SettingsProvider class.

Properties

ApplicationName

Gets or sets the name of the currently running application.

Description

Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).

(Inherited from ProviderBase)
Name

Gets the friendly name used to refer to the provider during configuration.

(Inherited from ProviderBase)

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetPropertyValues(SettingsContext, SettingsPropertyCollection)

Returns the collection of settings property values for the specified application instance and settings property group.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
Initialize(String, NameValueCollection)

Initializes the configuration builder.

(Inherited from ProviderBase)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetPropertyValues(SettingsContext, SettingsPropertyValueCollection)

Sets the values of the specified group of property settings.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also