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. 功能層級提供者接著會從設定檔讀取類型,並作為功能程式碼的 factory。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)

適用於