MembershipProviderCollection MembershipProviderCollection MembershipProviderCollection MembershipProviderCollection Class

定义

继承 MembershipProvider 抽象类的对象的集合。A collection of objects that inherit the MembershipProvider abstract class.

public ref class MembershipProviderCollection sealed : System::Configuration::Provider::ProviderCollection
public sealed class MembershipProviderCollection : System.Configuration.Provider.ProviderCollection
type MembershipProviderCollection = class
    inherit ProviderCollection
Public NotInheritable Class MembershipProviderCollection
Inherits ProviderCollection
继承
MembershipProviderCollectionMembershipProviderCollectionMembershipProviderCollectionMembershipProviderCollection

示例

下面的代码示例列出了为应用程序以及其各自的类型启用的提供程序。The following code example lists the providers enabled for an application and their respective types.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Configuration.Provider" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>List Enabled Providers</title>
</head>
<body>

<%
foreach (ProviderBase p in Membership.Providers)
  Response.Write(p.Name + ", " + p.GetType() + "<br />");
%>

</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Configuration.Provider" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>List Enabled Providers</title>
</head>
<body>

<%
For Each p As ProviderBase In Membership.Providers
  Response.Write(p.Name & ", " & p.GetType().ToString() & "<br />")
Next
%>

</body>
</html>

注解

应用程序的成员资格提供程序是MembershipProviderCollection ProvidersMembership类的属性以只读方式公开的。The membership providers for an application are exposed as a read-only MembershipProviderCollection by the Providers property of the Membership class. 您可以按名称访问集合中的特定成员资格提供程序, 并将其转换为特定的提供程序SqlMembershipProvider类型 (如)。You can access a specific membership provider in the collection by name and cast it as the specific provider type, such as SqlMembershipProvider. 这使您可以在单个应用程序中管理多个数据存储区中的成员身份信息, 以及访问不属于MembershipProvider抽象类的成员资格提供程序的自定义成员。This enables you to manage membership information from multiple data stores in a single application as well as access custom members of a membership provider that are not part of the MembershipProvider abstract class.

备注

如果你不熟悉 ASP.NET 的成员资格功能, 请参阅 "成员资格简介", 然后继续。If you are not familiar with the membership features of ASP.NET, see Introduction to Membership before continuing. 有关与成员资格相关的其他主题的列表, 请参阅使用成员身份管理用户For a list of other topics related to membership, see Managing Users by Using Membership.

构造函数

MembershipProviderCollection() MembershipProviderCollection() MembershipProviderCollection() MembershipProviderCollection()

创建一个新的空白成员资格提供程序集合。Creates a new, empty membership provider collection.

属性

Count Count Count Count

获取集合中提供程序的数目。Gets the number of providers in the collection.

(Inherited from ProviderCollection)
IsSynchronized IsSynchronized IsSynchronized IsSynchronized

获取一个值,该值指示对集合的访问是否为同步的(线程安全)。Gets a value indicating whether access to the collection is synchronized (thread safe).

(Inherited from ProviderCollection)
Item[String] Item[String] Item[String] Item[String]

获取集合中由指定的提供程序名称引用的成员资格提供程序。Gets the membership provider in the collection referenced by the specified provider name.

SyncRoot SyncRoot SyncRoot SyncRoot

获取当前对象。Gets the current object.

(Inherited from ProviderCollection)

方法

Add(ProviderBase) Add(ProviderBase) Add(ProviderBase) Add(ProviderBase)

将一个成员资格提供程序添加到该集合中。Adds a membership provider to the collection.

Clear() Clear() Clear() Clear()

从集合中移除所有项。Removes all items from the collection.

(Inherited from ProviderCollection)
CopyTo(MembershipProvider[], Int32) CopyTo(MembershipProvider[], Int32) CopyTo(MembershipProvider[], Int32) CopyTo(MembershipProvider[], Int32)

将成员资格提供程序集合复制到一维数组。Copies the membership provider collection to a one-dimensional array.

CopyTo(ProviderBase[], Int32) CopyTo(ProviderBase[], Int32) CopyTo(ProviderBase[], Int32) CopyTo(ProviderBase[], Int32)

从指定索引处开始,将集合中的内容复制到给定数组。Copies the contents of the collection to the given array starting at the specified index.

(Inherited from ProviderCollection)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回一个对象,该对象实现 IEnumerator 接口以循环访问集合。Returns an object that implements the IEnumerator interface to iterate through the collection.

(Inherited from ProviderCollection)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
Remove(String) Remove(String) Remove(String) Remove(String)

从集合中移除提供程序。Removes a provider from the collection.

(Inherited from ProviderCollection)
SetReadOnly() SetReadOnly() SetReadOnly() SetReadOnly()

将集合设置为只读。Sets the collection to be read-only.

(Inherited from ProviderCollection)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)

显式界面实现

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

ProviderCollection 的元素复制到一个数组中从特定的数组索引开始的位置。Copies the elements of the ProviderCollection to an array, starting at a particular array index.

(Inherited from ProviderCollection)

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅