SiteMapNodeCollection 類別

定義

提供 SiteMapNode 物件的強類型集合,並實作 IHierarchicalEnumerable 介面以支援整個集合的巡覽。

public ref class SiteMapNodeCollection : System::Collections::IList, System::Web::UI::IHierarchicalEnumerable
public class SiteMapNodeCollection : System.Collections.IList, System.Web.UI.IHierarchicalEnumerable
type SiteMapNodeCollection = class
    interface IHierarchicalEnumerable
    interface IList
    interface ICollection
    interface IEnumerable
type SiteMapNodeCollection = class
    interface IHierarchicalEnumerable
    interface IEnumerable
    interface IList
    interface ICollection
Public Class SiteMapNodeCollection
Implements IHierarchicalEnumerable, IList
繼承
SiteMapNodeCollection
實作

範例

下列程式碼範例示範如何建立 SiteMapNodeCollection 集合,然後使用 方法將物件加入 SiteMapNode 其中 AddRangeSiteMapNodeCollection是目前網站地圖的子集,只顯示前兩個階層式層級。


// Create a SiteMapNodeCollection with all the nodes
// from the first two hierarchical levels of the current
// site map.
SiteMapNodeCollection baseCollection =
    new SiteMapNodeCollection(SiteMap.RootNode);

SiteMapNodeCollection childCollection =
    SiteMap.RootNode.ChildNodes;

baseCollection.AddRange(childCollection);

Response.Write( "<BR>Derived SiteMapNodeCollection.<BR><HR><BR>");
foreach (SiteMapNode node in baseCollection) {
    Response.Write( node.Title + "<BR>");
}

' Create a SiteMapNodeCollection with all the nodes
' from the first two hierarchical levels of the current
' site map.
Dim baseCollection As SiteMapNodeCollection
baseCollection = New SiteMapNodeCollection(SiteMap.RootNode)

Dim childCollection As SiteMapNodeCollection = SiteMap.RootNode.ChildNodes

baseCollection.AddRange(childCollection)

Response.Write( "<BR>Derived SiteMapNodeCollection.<BR><HR><BR>")

For Each node In baseCollection
    Response.Write( node.Title + "<BR>")
Next

備註

類別 SiteMapNodeCollection 會提供 物件的強型別集合 SiteMapNode 。 它會在內部將物件儲存 SiteMapNode 在以零起始的陣列中。

您可以在第一 SiteMapNodeCollection 次建立集合時修改集合,然後使用下列方法來新增、複製和移除 SiteMapNode 物件:

您可以使用靜態 ReadOnly 方法來建立唯讀 SiteMapNodeCollection 的 ,不允許新增、複製或移除 SiteMapNode 物件。 SiteMapNodeCollectionGetChildren 方法所 SiteMapNode.GetAllNodes 傳回的集合是唯讀的,如同 SiteMapNodeCollection 在提供者傳回的物件上 SiteMapNode 存取屬性時 ChildNodes 所傳回的 。 NotSupportedException如果您嘗試藉由設定預設索引子屬性或使用下列任何方法修改唯讀 SiteMapNodeCollection ,就會擲回例外狀況:

IsReadOnly 呼叫上述清單中的任何方法之前,請使用 屬性來檢查集合。

建構函式

SiteMapNodeCollection()

初始化 SiteMapNodeCollection 類別的新執行個體,這個執行個體是預設的。

SiteMapNodeCollection(Int32)

使用指定的初始容量,初始化 SiteMapNodeCollection 類別的新執行個體。

SiteMapNodeCollection(SiteMapNode)

初始化 SiteMapNodeCollection 類別的新執行個體,並將 SiteMapNode 物件加入至集合的 InnerList 屬性。

SiteMapNodeCollection(SiteMapNode[])

初始化 SiteMapNodeCollection 類別的新執行個體,並將 SiteMapNode 型別陣列加入至集合的 InnerList 屬性。

SiteMapNodeCollection(SiteMapNodeCollection)

初始化 SiteMapNodeCollection 類別的新執行個體,並將指定之 SiteMapNodeCollection 集合的所有清單項目加入至集合的 InnerList 屬性。

屬性

Count

取得集合所包含的項目數目。

IsFixedSize

取得布林值,指出節點是否可以加入至集合或從集合減去。

IsReadOnly

取得布林值,指出集合是否為唯讀。

IsSynchronized

取得布林值,指出對集合的存取是否為同步的 (安全執行緒 (Thread-Safe))。

Item[Int32]

取得或設定位於集合中所指定索引處的 SiteMapNode 物件。

SyncRoot

取得物件,這個物件可以用來對集合進行同步存取。

方法

Add(SiteMapNode)

將單 SiteMapNode 一物件加入 SiteMapNodeCollection 至集合。

AddRange(SiteMapNode[])

SiteMapNode 型別陣列加入至集合。

AddRange(SiteMapNodeCollection)

將指定之 SiteMapNodeCollection 中的節點加入至目前集合。

Clear()

移除集合的所有項目。

Contains(SiteMapNode)

判斷集合是否含有指定的 SiteMapNode 物件。

CopyTo(SiteMapNode[], Int32)

從目標陣列的指定索引處開始,將整個集合複製到相容的一維陣列。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetDataSourceView(SiteMapDataSource, String)

擷取與目前集合中之節點關聯的 SiteMapDataSourceView 物件。

GetEnumerator()

擷取對列舉值物件的參考,這個物件是用來逐一查看集合。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetHierarchicalDataSourceView()

擷取與目前集合中之節點關聯的 SiteMapHierarchicalDataSourceView 物件。

GetHierarchyData(Object)

傳回指定列舉項目的階層式資料項目。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(SiteMapNode)

搜尋指定的 SiteMapNode 物件,然後傳回在整個集合中第一個符合元素之以零起始的索引。

Insert(Int32, SiteMapNode)

將指定的 SiteMapNode 物件插入至集合中所指定索引處。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnValidate(Object)

當驗證數值時,執行額外的自訂處理序。

ReadOnly(SiteMapNodeCollection)

傳回唯讀集合,其中包含指定之 SiteMapNodeCollection 集合中的節點。

Remove(SiteMapNode)

從集合中移除指定的 SiteMapNode 物件。

RemoveAt(Int32)

SiteMapNode移除集合之指定索引處的 SiteMapNodeCollection 物件。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從特定的陣列索引處開始,將 ICollection 介面的項目複製到陣列。 此類別無法獲得繼承。

ICollection.Count

取得 ICollection 介面中所包含的項目數。 此類別無法獲得繼承。

ICollection.IsSynchronized

取得 Boolean 值,指出對 ICollection 介面的存取是否為同步 (安全執行緒)。 此類別無法獲得繼承。

ICollection.SyncRoot

取得物件,可用來對 ICollection 介面進行同步存取。 此類別無法獲得繼承。

IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。 如需這個成員的說明,請參閱 GetEnumerator()

IHierarchicalEnumerable.GetHierarchyData(Object)

傳回指定列舉項目的階層式資料項目。 如需這個成員的說明,請參閱 GetHierarchyData(Object)

IList.Add(Object)

將項目加入至 IList 介面中的集合。 如需這個成員的說明,請參閱 Add(Object)

IList.Clear()

將所有項目從 IList 介面中的集合移除。 如需這個成員的說明,請參閱 Clear()

IList.Contains(Object)

判斷 IList 介面中的集合是否包含指定的布林值。

IList.IndexOf(Object)

判斷 IList 介面所傳回之集合中特定項目的索引。 如需這個成員的說明,請參閱 IndexOf(Object)

IList.Insert(Int32, Object)

將項目插入至 IList 介面的集合中指定之索引處。 如需這個成員的說明,請參閱 Insert(Int32, Object)

IList.IsFixedSize

取得 Boolean 值,指出集合是否具有固定大小。 如需這個成員的說明,請參閱 IsFixedSize

IList.IsReadOnly

取得 Boolean 值,指出集合是否為唯讀。 如需這個成員的說明,請參閱 IsReadOnly

IList.Item[Int32]

取得指定索引處的 IList 項目。

IList.Remove(Object)

IList 介面的集合中移除特定物件的第一個符合項目。 如需這個成員的說明,請參閱 Remove(Object)

IList.RemoveAt(Int32)

移除在指定索引處的 IList 項目。 如需這個成員的說明,請參閱 RemoveAt(Int32)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱