RoleProviderCollection 类

定义

继承 RoleProvider 抽象类的对象的集合。

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

示例

下面的代码示例列出了为应用程序启用的提供程序及其各自的类型。

<%@ 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 (RoleProvider p in Roles.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 RoleProvider In Roles.Providers
  Response.Write(p.Name & ", " & p.GetType().ToString() & "<br />")
Next
%>

</body>
</html>

注解

应用程序的角色提供程序由 Providers 类的 Roles 属性公开为只读RoleProviderCollection。 可以按名称访问集合中的特定角色提供程序,并将其转换为特定提供程序类型,例如 SqlRoleProvider。 这使你能够管理单个应用程序中多个数据存储中的角色信息,以及访问不属于抽象类的角色提供程序的 RoleProvider 自定义成员。

构造函数

RoleProviderCollection()

创建一个新的空角色提供程序集合。

属性

Count

获取集合中提供程序的数目。

(继承自 ProviderCollection)
IsSynchronized

获取一个值,该值指示对集合的访问是否为同步的(线程安全)。

(继承自 ProviderCollection)
Item[String]

获取集合中由指定的提供程序名称引用的角色提供程序。

SyncRoot

获取当前对象。

(继承自 ProviderCollection)

方法

Add(ProviderBase)

将一个角色提供程序添加到该集合中。

Clear()

从集合中移除所有项。

(继承自 ProviderCollection)
CopyTo(ProviderBase[], Int32)

从指定索引处开始,将集合中的内容复制到给定数组。

(继承自 ProviderCollection)
CopyTo(RoleProvider[], Int32)

将角色提供程序集合复制到一维数组中。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

返回一个对象,该对象实现 IEnumerator 接口以循环访问集合。

(继承自 ProviderCollection)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
Remove(String)

从集合中移除提供程序。

(继承自 ProviderCollection)
SetReadOnly()

将集合设置为只读。

(继承自 ProviderCollection)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

ICollection.CopyTo(Array, Int32)

ProviderCollection 的元素复制到一个数组中从特定的数组索引开始的位置。

(继承自 ProviderCollection)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

适用于

另请参阅