IApplicationSettingsProvider 接口

定义

为基于客户端的应用程序的设置提供程序定义扩展功能。Defines extended capabilities for client-based application settings providers.

public interface class IApplicationSettingsProvider
public interface IApplicationSettingsProvider
type IApplicationSettingsProvider = interface
Public Interface IApplicationSettingsProvider
派生

注解

利用应用程序设置体系结构,你可以通过创建自定义设置提供程序(一个派生自的类)为应用程序设置提供自定义存储机制 SettingsProviderThe application settings architecture enables you to provide a custom storage mechanism for application settings by creating a custom settings provider, which is a class derived from SettingsProvider. 此类包含用于存储和检索属性的基本功能。Such a class contains the basic functionality for storing and retrieving properties. 但是,您可以通过 IApplicationSettingsProvider 在自定义设置提供程序中实现接口来添加其他标准化功能。However, you can add additional standardized functionality by implementing the IApplicationSettingsProvider interface in the custom settings provider. 此接口包含三种方法,这些方法主要使设置提供程序能够更智能地处理应用程序版本更改。This interface contains three methods that primarily enable the settings provider to more intelligently handle application version changes. 通常,设置提供程序将单独存储不同版本的应用程序的应用程序设置,以预见以下情况:Typically, the settings provider will store application settings for different versions of an application separately to anticipate the following circumstances:

  • 并行执行不同版本的应用程序。Side-by-side execution of different versions of an application.

  • 升级应用程序时保留应用程序设置。Retaining application settings when upgrading an application.

  • 将应用程序设置重置为当前所使用版本的默认值。Resetting the application settings to their default values for the currently used version.

LocalFileSettingsProvider 类实现 IApplicationSettingsProvider 接口。The LocalFileSettingsProvider class implements the IApplicationSettingsProvider interface. 类中还提供了包含的一组相同的方法 IApplicationSettingsProvider ApplicationSettingsBase ,以便在应用程序设置包装器和其设置提供程序之间建立预定义的通信通道。The same set of methods contained by IApplicationSettingsProvider is also found in the ApplicationSettingsBase class, enabling the establishment of a predefined communication channel between an application settings wrapper and its settings provider.

备注

此接口是可选的。This interface is optional. 如果提供程序未实现此接口,则设置基础结构将在尝试访问此接口定义的任何方法时无通知就会失败。If a provider does not implement this interface, the settings infrastructure will fail without notification if it attempts to access any of the methods defined by this interface.

方法

GetPreviousVersion(SettingsContext, SettingsProperty)

返回同一应用程序早期版本的指定设置属性的值。Returns the value of the specified settings property for the previous version of the same application.

Reset(SettingsContext)

将与指定应用程序关联的应用程序设置重置为其默认值。Resets the application settings associated with the specified application to their default values.

Upgrade(SettingsContext, SettingsPropertyCollection)

向提供程序指出应用程序已升级。Indicates to the provider that the application has been upgraded. 这给提供程序提供了一个机会,使其可以相应地升级其存储的设置。This offers the provider an opportunity to upgrade its stored settings as appropriate.

适用于

另请参阅