SiteMapProviderCollection 類別

定義

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
繼承
SiteMapProviderCollection

範例

下列程式碼範例示範如何 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>

備註

SiteMapProviderCollection類別是物件的強型別 Hashtable 集合 SiteMapProviderThe SiteMapProviderCollection class is a strongly typed Hashtable collection of SiteMapProvider objects. 除了這兩個 add 方法之外, Add(ProviderBase)Add(SiteMapProvider)SiteMapProviderCollection 類別也支援 AddArray 方法來加入型別的陣列 SiteMapProviderIn 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.

SiteMapProviderCollection類別會使用 SiteMap 來追蹤在 SiteMapProvider 網站地圖初始化期間可供使用的物件集合 SiteMapThe 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.

SiteMapProvider 儲存在中時 SiteMapProviderCollectionName 會使用屬性做為索引鍵。When a SiteMapProvider is stored in the SiteMapProviderCollection, the Name property is used as the key.

建構函式

SiteMapProviderCollection()

初始化 SiteMapProviderCollection 類別的新執行個體。Initializes a new instance of the SiteMapProviderCollection class.

屬性

Count

取得集合中的提供者數目。Gets the number of providers in the collection.

(繼承來源 ProviderCollection)
IsSynchronized

取得值,表示是否同步化存取集合 (執行緒安全)。Gets a value indicating whether access to the collection is synchronized (thread safe).

(繼承來源 ProviderCollection)
Item[String]

從提供者集合中,取得特定名稱的 SiteMapProvider 物件。Gets a SiteMapProvider object with a specific name from the provider collection.

SyncRoot

取得目前的物件。Gets the current object.

(繼承來源 ProviderCollection)

方法

Add(ProviderBase)

使用 SiteMapProvider 屬性做為索引鍵,將 Name 加入至提供者集合。Adds a SiteMapProvider to the provider collection using the Name property as the key.

Add(SiteMapProvider)

使用 SiteMapProvider 屬性做為索引鍵,將 Name 物件加入至提供者集合。Adds a SiteMapProvider object to the provider collection using the Name property as the key.

AddArray(SiteMapProvider[])

使用 SiteMapProvider 屬性做為索引鍵,將 Name 物件的陣列加入至提供者集合。Adds an array of SiteMapProvider objects into the provider collection using the Name properties as keys.

Clear()

移除集合的所有項目。Removes all items from the collection.

(繼承來源 ProviderCollection)
CopyTo(ProviderBase[], Int32)

從指定之索引處開始,將集合的內容複製到指定的陣列。Copies the contents of the collection to the given array starting at the specified index.

(繼承來源 ProviderCollection)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()

傳回實作 IEnumerator 介面以逐一查看集合的物件。Returns an object that implements the IEnumerator interface to iterate through the collection.

(繼承來源 ProviderCollection)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(String)

從集合移除提供者。Removes a provider from the collection.

(繼承來源 ProviderCollection)
SetReadOnly()

將集合設定為唯讀。Sets the collection to be read-only.

(繼承來源 ProviderCollection)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從特定的陣列索引開始,將 ProviderCollection 的項目複製到陣列中。Copies the elements of the ProviderCollection to an array, starting at a particular array index.

(繼承來源 ProviderCollection)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱