SiteMapProviderCollection SiteMapProviderCollection SiteMapProviderCollection SiteMapProviderCollection Class

定义

SiteMap 类用于跟踪在站点地图初始化期间对 SiteMapProvider 可用的 SiteMap 对象集。Used by the SiteMap class to track the set of SiteMapProvider objects that are available to the SiteMap during site map initialization. 此类不能被继承。This class cannot be inherited.

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

示例

下面的代码示例演示如何SiteMapProviderCollection SiteMap从对象检索对象并对其进行循环访问。The following code example demonstrates how to retrieve the SiteMapProviderCollection object from the SiteMap object and iterate through it.

如果你的网站不只是为站点配置的默认提供程序, 则会看到显示的每个提供程序。If you have more than just the default provider configured for your site, you will see each provider that is displayed. 例如, 如果使用AccessSiteMapProvider SiteMapProvider类概述中的示例, 则会看到以下输出。For example, if you are using the sample AccessSiteMapProvider found in the SiteMapProvider class overview, you will see the following output.

XmlSiteMapProvider   System.Web.XmlSiteMapProvider  
AccessSiteMapProvider   Samples.AspNet.Controls.AccessSiteMapProvider  
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
    // Navigate the SiteMap built by the default SiteMapProvider.
    Response.Write(SiteMap.RootNode.ToString() + "<BR>");

    Response.Write(SiteMap.RootNode.Url + "<BR>");
    Response.Write(SiteMap.RootNode.Title + "<BR>");

    foreach (SiteMapNode sitemapnode in SiteMap.RootNode.ChildNodes)
    {
        // Iterate through the ChildNodes SiteMapNodesCollection
        // maintained by the RootNode.
        Response.Write(sitemapnode.Url + "<BR>" );
    }

    IEnumerator providers = SiteMap.Providers.GetEnumerator();
    while (providers.MoveNext())
    {
        Response.Write(providers.Current);
        Response.Write("&nbsp;&nbsp;&nbsp;");
        Response.Write("<BR>");
    }
}
</SCRIPT>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
Private Sub Page_Load(Sender As Object, E As EventArgs)

    ' Navigate the SiteMap built by the default SiteMapProvider.
    Response.Write(SiteMap.RootNode.ToString() & "<BR>")

    Response.Write(SiteMap.RootNode.Url & "<BR>")
    Response.Write(SiteMap.RootNode.Title & "<BR>")

    Dim sitemapnode As SiteMapNode
    For Each sitemapnode In SiteMap.RootNode.ChildNodes
        ' Iterate through the ChildNodes SiteMapNodesCollection
        ' maintained by the RootNode.
        Response.Write(sitemapnode.Url & "<BR>" )
    Next

    Dim providers As IDictionaryEnumerator = SiteMap.Providers.GetEnumerator()
    While (providers.MoveNext())
        Response.Write(providers.Current)
        Response.Write("&nbsp;&nbsp;&nbsp;")
        Response.Write("<BR>")
    End While
End Sub ' Page_Load

</SCRIPT>

注解

类是SiteMapProvider对象的强类型Hashtable集合。 SiteMapProviderCollectionThe SiteMapProviderCollection class is a strongly typed Hashtable collection of SiteMapProvider objects. 除了这两个添加方法Add(ProviderBase) (和AddArray Add(SiteMapProvider)) SiteMapProviderCollection , 类还支持方法来添加类型SiteMapProvider的数组。In addition to the two add methods, Add(ProviderBase) and Add(SiteMapProvider), the SiteMapProviderCollection class supports the AddArray method to add an array of type SiteMapProvider.

由类用于SiteMapProvider跟踪对象的集合, 这些对象可用于SiteMap在站点地图初始化期间使用。 SiteMap SiteMapProviderCollectionThe SiteMapProviderCollection is used by the SiteMap class to track the set of SiteMapProvider objects that are available to the SiteMap during site map initialization. 但是, 提供程序集合SiteMapProvider中的存在并不一定意味着它仅供某个SiteMap对象使用。However, the presence of a SiteMapProvider in the provider collection does not necessarily mean it is used by a SiteMap object, only that it is available for use.

当存储在中时Name ,属性将用作键。SiteMapProviderCollection SiteMapProviderWhen a SiteMapProvider is stored in the SiteMapProviderCollection, the Name property is used as the key.

构造函数

SiteMapProviderCollection() SiteMapProviderCollection() SiteMapProviderCollection() SiteMapProviderCollection()

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

属性

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]

从提供程序集合获取具有特定名称的 SiteMapProvider 对象。Gets a SiteMapProvider object with a specific name from the provider collection.

SyncRoot SyncRoot SyncRoot SyncRoot

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

(Inherited from ProviderCollection)

方法

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

使用 SiteMapProvider 属性作为键向提供程序集合添加一个 NameAdds a SiteMapProvider to the provider collection using the Name property as the key.

Add(SiteMapProvider) Add(SiteMapProvider) Add(SiteMapProvider) Add(SiteMapProvider)

使用 SiteMapProvider 属性作为键向提供程序集合添加一个 Name 对象。Adds a SiteMapProvider object to the provider collection using the Name property as the key.

AddArray(SiteMapProvider[]) AddArray(SiteMapProvider[]) AddArray(SiteMapProvider[]) AddArray(SiteMapProvider[])

使用 SiteMapProvider 属性作为键将 Name 对象的数组添加到提供程序集合中。Adds an array of SiteMapProvider objects into the provider collection using the Name properties as keys.

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

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

(Inherited from ProviderCollection)
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.

适用于

另请参阅