Export (0) Print
Expand All

SiteMapNodeCollection Class

Provides a strongly typed collection for SiteMapNode objects and implements the IHierarchicalEnumerable interface to support navigating through the collection.

System.Object
  System.Web.SiteMapNodeCollection

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public class SiteMapNodeCollection : IHierarchicalEnumerable, 
	IList, ICollection, IEnumerable

The SiteMapNodeCollection type exposes the following members.

  NameDescription
Public methodSiteMapNodeCollection()Initializes a new instance of the SiteMapNodeCollection class, which is the default instance.
Public methodSiteMapNodeCollection(Int32)Initializes a new instance of the SiteMapNodeCollection class with the specified initial capacity.
Public methodSiteMapNodeCollection(SiteMapNode)Initializes a new instance of the SiteMapNodeCollection class and adds the SiteMapNode object to the InnerList property for the collection.
Public methodSiteMapNodeCollection(SiteMapNode[])Initializes a new instance of the SiteMapNodeCollection class and adds the array of type SiteMapNode to the InnerList property for the collection.
Public methodSiteMapNodeCollection(SiteMapNodeCollection)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.
Top

  NameDescription
Public propertyCountGets the number of elements contained in the collection.
Public propertyIsFixedSizeGets a Boolean value indicating whether nodes can be added to or subtracted from the collection.
Public propertyIsReadOnlyGets a Boolean value indicating whether the collection is read-only.
Public propertyIsSynchronizedGets a Boolean value indicating whether access to the collection is synchronized (thread safe).
Public propertyItemGets or sets the SiteMapNode object at the specified index in the collection.
Public propertySyncRootGets an object that can be used to synchronize access to the collection.
Top

  NameDescription
Public methodAddAdds a single SiteMapNode object to the collection.
Public methodAddRange(SiteMapNode[])Adds an array of type SiteMapNode to the collection.
Public methodAddRange(SiteMapNodeCollection)Adds the nodes in the specified SiteMapNodeCollection to the current collection.
Public methodClearRemoves all items from the collection.
Public methodContainsDetermines whether the collection contains a specific SiteMapNode object.
Public methodCopyToCopies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetDataSourceViewRetrieves the SiteMapDataSourceView object that is associated with the nodes in the current collection.
Public methodGetEnumeratorRetrieves a reference to an enumerator object, which is used to iterate over the collection.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetHierarchicalDataSourceViewRetrieves the SiteMapHierarchicalDataSourceView object that is associated with the nodes in the current collection.
Public methodGetHierarchyDataReturns a hierarchical data item for the specified enumerated item.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfSearches for the specified SiteMapNode object, and then returns the zero-based index of the first occurrence within the entire collection.
Public methodInsertInserts the specified SiteMapNode object into the collection at the specified index.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnValidatePerforms additional custom processes when validating a value.
Public methodStatic memberReadOnlyReturns a read-only collection that contains the nodes in the specified SiteMapNodeCollection collection.
Public methodRemoveRemoves the specified SiteMapNode object from the collection.
Public methodRemoveAtRemoves the SiteMapNode object at the specified index of the collection.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast<TResult>Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType<TResult>Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToInfrastructure. Copies the elements of the ICollection interface to an array, starting at a particular array index. This class cannot be inherited.
Explicit interface implemetationPrivate propertyICollection.CountInfrastructure. Gets the number of elements that are contained in the ICollection interface. This class cannot be inherited.
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedInfrastructure. Gets a Boolean value indicating whether access to the ICollection interface is synchronized (thread safe). This class cannot be inherited.
Explicit interface implemetationPrivate propertyICollection.SyncRootInfrastructure. Gets an object that can be used to synchronize access to the ICollection interface. This class cannot be inherited.
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorInfrastructure. Returns an enumerator that iterates through a collection. For a description of this member, see IEnumerable.GetEnumerator.
Explicit interface implemetationPrivate methodIHierarchicalEnumerable.GetHierarchyDataInfrastructure. Returns a hierarchical data item for the specified enumerated item. For a description of this member, see IHierarchicalEnumerable.GetHierarchyData.
Explicit interface implemetationPrivate methodIList.AddInfrastructure. Adds an item to the collection in the IList interface. For a description of this member, see IList.Add.
Explicit interface implemetationPrivate methodIList.ClearInfrastructure. Removes all items from the collection in the IList interface. For a description of this member, see IList.Clear.
Explicit interface implemetationPrivate methodIList.ContainsDetermines whether the collection in the IList interface contains the specified Boolean value.
Explicit interface implemetationPrivate methodIList.IndexOfInfrastructure. Determines the index of the specific item in the collection that is returned by the IList interface. For a description of this member, see IList.IndexOf.
Explicit interface implemetationPrivate methodIList.InsertInfrastructure. Inserts an item into the collection in the IList interface at the specified index. For a description of this member, see IList.Insert.
Explicit interface implemetationPrivate propertyIList.IsFixedSizeInfrastructure. Gets a Boolean value indicating whether the collection has a fixed size. For a description of this member, see IList.IsFixedSize.
Explicit interface implemetationPrivate propertyIList.IsReadOnlyInfrastructure. Gets a Boolean value indicating whether the collection is read-only. For a description of this member, see IList.IsReadOnly.
Explicit interface implemetationPrivate propertyIList.ItemInfrastructure. Gets the IList element at the specified index.
Explicit interface implemetationPrivate methodIList.RemoveInfrastructure. Removes the first occurrence of a specified object from the collection in the IList interface. For a description of this member, see IList.Remove.
Explicit interface implemetationPrivate methodIList.RemoveAtInfrastructure. Removes the IList item at the specified index. For a description of this member, see IList.RemoveAt.
Top

The SiteMapNodeCollection class provides a strongly typed collection for SiteMapNode objects. It stores SiteMapNode objects internally in a zero-based array.

You can modify a SiteMapNodeCollection collection when it is first created, and then use the following methods to add, copy, and remove SiteMapNode objects:

You can create a read-only SiteMapNodeCollection, which does not permit adding, copying, nor removing SiteMapNode objects, by using the static ReadOnly method. 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. A 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:

Use the IsReadOnly property to check the collection before calling any of the methods in the preceding list.

The following code example demonstrates how to create a SiteMapNodeCollection collection, and then add SiteMapNode objects to it using the AddRange method. 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>");
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft