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集合,然后使用该方法向其AddRange添加SiteMapNode对象。 这是 SiteMapNodeCollection 当前站点地图的子集,仅显示前两个层次结构级别。


// 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对象。 SiteMapNodeCollectionSiteMapNode.GetAllNodes方法GetChildren返回的集合是只读的,就像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

获取一个 Boolean 值,该值指示是否可以在集合中增减节点。

IsReadOnly

获取一个 Boolean 值,该值指示集合是否为只读。

IsSynchronized

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

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

适用于

另请参阅