SiteMapNodeCollection SiteMapNodeCollection SiteMapNodeCollection SiteMapNodeCollection Class

定义

提供 SiteMapNode 对象的强类型化集合,并实现 IHierarchicalEnumerable 接口以支持在该集合中进行导航。Provides a strongly typed collection for SiteMapNode objects and implements the IHierarchicalEnumerable interface to support navigating through the collection.

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 IEnumerable
    interface IList
    interface ICollection
Public Class SiteMapNodeCollection
Implements IHierarchicalEnumerable, IList
继承
SiteMapNodeCollectionSiteMapNodeCollectionSiteMapNodeCollectionSiteMapNodeCollection
实现

示例

下面的代码示例演示如何创建SiteMapNodeCollection集合, 然后使用AddRange方法将对象SiteMapNode添加到其中。The following code example demonstrates how to create a SiteMapNodeCollection collection, and then add SiteMapNode objects to it using the AddRange method. SiteMapNodeCollection是当前站点地图的子集, 只显示前两个层次结构级别。The SiteMapNodeCollection is a subset of the current site map, showing only the first two hierarchical levels.


// 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

注解

类提供SiteMapNode对象的强类型集合。 SiteMapNodeCollectionThe SiteMapNodeCollection class provides a strongly typed collection for SiteMapNode objects. 它在SiteMapNode从零开始的数组中存储对象。It stores SiteMapNode objects internally in a zero-based array.

首次创建SiteMapNodeCollection集合时, 你可以修改它, 然后使用以下方法添加、复制和删除SiteMapNode对象:You can modify a SiteMapNodeCollection collection when it is first created, and then use the following methods to add, copy, and remove SiteMapNode objects:

您可以使用静态SiteMapNodeCollection ReadOnly方法创建不允许添加、复制和删除SiteMapNode对象的只读。You can create a read-only SiteMapNodeCollection, which does not permit adding, copying, nor removing SiteMapNode objects, by using the static ReadOnly method. SiteMapNode.GetAllNodes ChildNodes SiteMapNodeSiteMapNodeCollection 方法GetChildren返回的集合SiteMapNodeCollection是只读的, 这与在从返回的对象上访问该属性时返回的对象是只读的。程序.The SiteMapNodeCollection collections that are returned by the SiteMapNode.GetAllNodes and GetChildren methods are read-only, as is the SiteMapNodeCollection that is returned when the ChildNodes property is accessed on a SiteMapNode object that is returned from a provider. 如果尝试SiteMapNodeCollection通过设置默认索引器属性或使用以下任一方法修改只读, 则会引发异常:NotSupportedExceptionA NotSupportedException exception is thrown, if you attempt to modify a read-only SiteMapNodeCollection by setting the default indexer property or by using any of the following methods:

在调用上述列表中的任何方法之前, 请使用属性来检查集合。IsReadOnlyUse the IsReadOnly property to check the collection before calling any of the methods in the preceding list.

构造函数

SiteMapNodeCollection() SiteMapNodeCollection() SiteMapNodeCollection() SiteMapNodeCollection()

初始化 SiteMapNodeCollection 类的新实例,也是默认实例。Initializes a new instance of the SiteMapNodeCollection class, which is the default instance.

SiteMapNodeCollection(Int32) SiteMapNodeCollection(Int32) SiteMapNodeCollection(Int32) SiteMapNodeCollection(Int32)

使用指定的初始容量初始化 SiteMapNodeCollection 类的新实例。Initializes a new instance of the SiteMapNodeCollection class with the specified initial capacity.

SiteMapNodeCollection(SiteMapNode) SiteMapNodeCollection(SiteMapNode) SiteMapNodeCollection(SiteMapNode) SiteMapNodeCollection(SiteMapNode)

SiteMapNodeCollection 类的新实例进行初始化,然后将 SiteMapNode 对象添加到该集合的 InnerList 属性中。Initializes a new instance of the SiteMapNodeCollection class and adds the SiteMapNode object to the InnerList property for the collection.

SiteMapNodeCollection(SiteMapNodeCollection) SiteMapNodeCollection(SiteMapNodeCollection) SiteMapNodeCollection(SiteMapNodeCollection) SiteMapNodeCollection(SiteMapNodeCollection)

SiteMapNodeCollection 类的新实例进行初始化,然后将指定的 SiteMapNodeCollection 集合的所有列表项添加到该集合的 InnerList 属性中。Initializes a new instance of the SiteMapNodeCollection class and adds all the list items of the specified SiteMapNodeCollection collection to the InnerList property for the collection.

SiteMapNodeCollection(SiteMapNode[]) SiteMapNodeCollection(SiteMapNode[]) SiteMapNodeCollection(SiteMapNode[]) SiteMapNodeCollection(SiteMapNode[])

SiteMapNodeCollection 类的新实例进行初始化,然后将类型 SiteMapNode 的数组添加到该集合的 InnerList 属性中。Initializes a new instance of the SiteMapNodeCollection class and adds the array of type SiteMapNode to the InnerList property for the collection.

属性

Count Count Count Count

获取集合中包含的元素数。Gets the number of elements contained in the collection.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

获取一个 Boolean 值,该值指示是否可以在集合中增减节点。Gets a Boolean value indicating whether nodes can be added to or subtracted from the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取一个 Boolean 值,该值指示集合是否为只读。Gets a Boolean value indicating whether the collection is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取或设置集合中指定索引处的 SiteMapNode 对象。Gets or sets the SiteMapNode object at the specified index in the collection.

SyncRoot SyncRoot SyncRoot SyncRoot

获取可用于同步对集合的访问的对象。Gets an object that can be used to synchronize access to the collection.

方法

Add(SiteMapNode) Add(SiteMapNode) Add(SiteMapNode) Add(SiteMapNode)

将一个 SiteMapNode 对象添加到集合中。Adds a single SiteMapNode object to the collection.

AddRange(SiteMapNodeCollection) AddRange(SiteMapNodeCollection) AddRange(SiteMapNodeCollection) AddRange(SiteMapNodeCollection)

将指定的 SiteMapNodeCollection 中的节点添加到当前集合。Adds the nodes in the specified SiteMapNodeCollection to the current collection.

AddRange(SiteMapNode[]) AddRange(SiteMapNode[]) AddRange(SiteMapNode[]) AddRange(SiteMapNode[])

向集合添加 SiteMapNode 类型的数组。Adds an array of type SiteMapNode to the collection.

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

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

Contains(SiteMapNode) Contains(SiteMapNode) Contains(SiteMapNode) Contains(SiteMapNode)

确定集合是否包含特定的 SiteMapNode 对象。Determines whether the collection contains a specific SiteMapNode object.

CopyTo(SiteMapNode[], Int32) CopyTo(SiteMapNode[], Int32) CopyTo(SiteMapNode[], Int32) CopyTo(SiteMapNode[], Int32)

从目标数组的指定索引处开始,将整个集合复制到兼容的一维数组。Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetDataSourceView(SiteMapDataSource, String) GetDataSourceView(SiteMapDataSource, String) GetDataSourceView(SiteMapDataSource, String) GetDataSourceView(SiteMapDataSource, String)

检索与当前集合中的节点关联的 SiteMapDataSourceView 对象。Retrieves the SiteMapDataSourceView object that is associated with the nodes in the current collection.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

检索对枚举数对象的引用,该对象用于对集合进行循环访问。Retrieves a reference to an enumerator object, which is used to iterate over the collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetHierarchicalDataSourceView() GetHierarchicalDataSourceView() GetHierarchicalDataSourceView() GetHierarchicalDataSourceView()

检索与当前集合中的节点关联的 SiteMapHierarchicalDataSourceView 对象。Retrieves the SiteMapHierarchicalDataSourceView object that is associated with the nodes in the current collection.

GetHierarchyData(Object) GetHierarchyData(Object) GetHierarchyData(Object) GetHierarchyData(Object)

返回指定枚举项的分层数据项。Returns a hierarchical data item for the specified enumerated item.

GetType() GetType() GetType() GetType()

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

(Inherited from Object)
IndexOf(SiteMapNode) IndexOf(SiteMapNode) IndexOf(SiteMapNode) IndexOf(SiteMapNode)

搜索指定的 SiteMapNode 对象,并返回整个集合中第一个匹配项的从零开始的索引。Searches for the specified SiteMapNode object, and then returns the zero-based index of the first occurrence within the entire collection.

Insert(Int32, SiteMapNode) Insert(Int32, SiteMapNode) Insert(Int32, SiteMapNode) Insert(Int32, SiteMapNode)

将指定的 SiteMapNode 对象插入集合中指定的索引位置。Inserts the specified SiteMapNode object into the collection at the specified index.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
OnValidate(Object) OnValidate(Object) OnValidate(Object) OnValidate(Object)

当验证值时执行其他自定义进程。Performs additional custom processes when validating a value.

ReadOnly(SiteMapNodeCollection) ReadOnly(SiteMapNodeCollection) ReadOnly(SiteMapNodeCollection) ReadOnly(SiteMapNodeCollection)

返回一个只读集合,其中包含指定的 SiteMapNodeCollection 集合中的节点。Returns a read-only collection that contains the nodes in the specified SiteMapNodeCollection collection.

Remove(SiteMapNode) Remove(SiteMapNode) Remove(SiteMapNode) Remove(SiteMapNode)

从集合中移除指定的 SiteMapNode 对象。Removes the specified SiteMapNode object from the collection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

从集合中移除位于指定索引位置的 SiteMapNode 对象。Removes the SiteMapNode object at the specified index of the collection.

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)

ICollection 接口的元素复制到一个数组中从特定的数组索引开始的位置。Copies the elements of the ICollection interface to an array, starting at a particular array index. 此类不能被继承。This class cannot be inherited.

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

获取 ICollection 接口中包含的元素数。Gets the number of elements that are contained in the ICollection interface. 此类不能被继承。This class cannot be inherited.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

获取一个 Boolean 值,该值指示对 ICollection 接口的访问是否是同步的(线程安全)。Gets a Boolean value indicating whether access to the ICollection interface is synchronized (thread safe). 此类不能被继承。This class cannot be inherited.

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

获取可用于同步对 ICollection 接口的访问的对象。Gets an object that can be used to synchronize access to the ICollection interface. 此类不能被继承。This class cannot be inherited.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

返回循环访问集合的枚举数。Returns an enumerator that iterates through a collection. 有关此成员的说明,请参见 GetEnumerator()For a description of this member, see GetEnumerator().

IHierarchicalEnumerable.GetHierarchyData(Object) IHierarchicalEnumerable.GetHierarchyData(Object) IHierarchicalEnumerable.GetHierarchyData(Object) IHierarchicalEnumerable.GetHierarchyData(Object)

返回指定枚举项的分层数据项。Returns a hierarchical data item for the specified enumerated item. 有关此成员的说明,请参见 GetHierarchyData(Object)For a description of this member, see GetHierarchyData(Object).

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

IList 接口的集合中添加一项。Adds an item to the collection in the IList interface. 有关此成员的说明,请参见 Add(Object)For a description of this member, see Add(Object).

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

IList 接口的集合中移除所有项。Removes all items from the collection in the IList interface. 有关此成员的说明,请参见 Clear()For a description of this member, see Clear().

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

确定 IList 接口的集合中是否包含指定的布尔值。Determines whether the collection in the IList interface contains the specified Boolean value.

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

确定集合中特定项的索引,该集合由 IList 接口返回。Determines the index of the specific item in the collection that is returned by the IList interface. 有关此成员的说明,请参见 IndexOf(Object)For a description of this member, see IndexOf(Object).

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

将一项插入 IList 接口中的集合中的指定索引处。Inserts an item into the collection in the IList interface at the specified index. 有关此成员的说明,请参见 Insert(Int32, Object)For a description of this member, see Insert(Int32, Object).

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

获取一个 Boolean 值,该值指示集合是否具有固定大小。Gets a Boolean value indicating whether the collection has a fixed size. 有关此成员的说明,请参见 IsFixedSizeFor a description of this member, see IsFixedSize.

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

获取一个 Boolean 值,该值指示集合是否为只读。Gets a Boolean value indicating whether the collection is read-only. 有关此成员的说明,请参见 IsReadOnlyFor a description of this member, see IsReadOnly.

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

获取指定索引处的 IList 元素。Gets the IList element at the specified index.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

IList 接口的集合中移除指定对象的第一个匹配项。Removes the first occurrence of a specified object from the collection in the IList interface. 有关此成员的说明,请参见 Remove(Object)For a description of this member, see Remove(Object).

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

移除位于指定索引处的 IList 项。Removes the IList item at the specified index. 有关此成员的说明,请参见 RemoveAt(Int32)For a description of this member, see RemoveAt(Int32).

扩展方法

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.

适用于

另请参阅