ProviderBase 类

定义

提供了针对可扩展的提供程序模型的基实现。Provides a base implementation for the extensible provider model.

public ref class ProviderBase abstract
public abstract class ProviderBase
type ProviderBase = class
Public MustInherit Class ProviderBase
继承
ProviderBase
派生

示例

有关如何使用ProviderBase类的示例, 请参阅分析提供程序实现示例For an example of how to use the ProviderBase class, see Profile Provider Implementation Example.

注解

提供程序模型旨在封装多个 ASP.NET 功能的全部或部分功能, 例如成员身份、配置文件和受保护配置。The provider model is intended to encapsulate all or part of the functionality of multiple ASP.NET features, such as membership, profiles, and protected configuration. 它允许开发人员创建提供封装功能的多个实现的支持类。It allows the developer to create supporting classes that provide multiple implementations of the encapsulated functionality. 此外, 开发人员可以使用提供程序模型编写新功能。In addition, developers can write new features using the provider model. 如果需要更改实现方法, 这可能是一种有效的方法, 可支持功能的多个实现, 而无需复制功能代码或对应用程序层进行编码。This can be an effective way to support multiple implementations of a feature's functionality without duplicating the feature code or recoding the application layer if the implementation method needs to be changed.

ProviderBase类很简单, 只包含一些对所有提供程序通用的基本方法和属性。The ProviderBase class is simple, containing only a few basic methods and properties that are common to all providers. 特定于功能的提供程序 ( MembershipProvider如) 从ProviderBase继承, 并建立该功能的特定于实现的提供程序必须支持的必要方法和属性。Feature-specific providers (such as MembershipProvider) inherit from ProviderBase and establish the necessary methods and properties that the implementation-specific providers for that feature must support. 特定于实现的提供程序 ( SqlMembershipProvider如) 从特定于功能的提供程序 (在本例MembershipProvider中为) 继承。Implementation-specific providers (such as SqlMembershipProvider) inherit in turn from a feature-specific provider (in this case, MembershipProvider).

提供程序模型的最重要方面是, 实现 (例如, 数据是保存为文本文件还是数据库中) 是从应用程序代码中提取的。The most important aspect of the provider model is that the implementation (for example, whether data is persisted as a text file or in a database) is abstracted from the application code. 给定功能的特定于实现的提供程序的类型是在配置文件中指定的。The type of the implementation-specific provider for the given feature is designated in a configuration file. 然后, 功能级别提供程序从配置文件中读取类型并充当功能代码的工厂。The feature-level provider then reads in the type from the configuration file and acts as a factory to the feature code. 然后, 应用程序开发人员可以在应用程序代码中使用功能类。The application developer can then use the feature classes in the application code. 实现类型可以在配置文件中换出, 无需重写代码来容纳不同的实现方法。The implementation type can be swapped out in the configuration file, eliminating the need to rewrite the code to accommodate the different implementation methodology.

ASP.NET 中包含的提供程序主要用于功能 (如配置文件或成员身份) 的数据持久性实现。The providers included with ASP.NET are mostly abstractions of data persistence implementations for features like profiles or membership. 但是, 可以将此模型应用于任何其他类型的功能, 这些功能可通过多种方式进行抽象和实现。However, this model can be applied to any other kind of feature functionality that could be abstracted and implemented in multiple ways.

构造函数

ProviderBase()

初始化 ProviderBase 类的新实例。Initializes a new instance of the ProviderBase class.

属性

Description

获取一条简短的易懂描述,它适合在管理工具或其他用户界面 (UI) 中显示。Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).

Name

获得一个友好名称,用于在配置过程中引用提供程序。Gets the friendly name used to refer to the provider during configuration.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Initialize(String, NameValueCollection)

初始化配置生成器。Initializes the configuration builder.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅