SiteMapNodeCollection Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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 IList
interface ICollection
interface IEnumerable
type SiteMapNodeCollection = class
interface IHierarchicalEnumerable
interface IEnumerable
interface IList
interface ICollection
Public Class SiteMapNodeCollection
Implements IHierarchicalEnumerable, IList
- Inheritance
-
SiteMapNodeCollection
- Implements
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>");
}
' 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
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:
To add SiteMapNode objects, use the Add, AddRange, and Insert methods.
To copy SiteMapNode objects, use the CopyTo method.
To remove SiteMapNode objects, use the Remove method.
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.
Site |
Initializes a new instance of the SiteMapNodeCollection class, which is the default instance. |
Site |
Initializes a new instance of the SiteMapNodeCollection class with the specified initial capacity. |
Site |
Initializes a new instance of the SiteMapNodeCollection class and adds the SiteMapNode object to the InnerList property for the collection. |
Site |
Initializes a new instance of the SiteMapNodeCollection class and adds the array of type SiteMapNode to the InnerList property for the collection. |
Site |
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. |
Count |
Gets the number of elements contained in the collection. |
Is |
Gets a Boolean value indicating whether nodes can be added to or subtracted from the collection. |
Is |
Gets a Boolean value indicating whether the collection is read-only. |
Is |
Gets a Boolean value indicating whether access to the collection is synchronized (thread safe). |
Item[Int32] |
Gets or sets the SiteMapNode object at the specified index in the collection. |
Sync |
Gets an object that can be used to synchronize access to the collection. |
Add(Site |
Adds a single SiteMapNode object to the SiteMapNodeCollection collection. |
Add |
Adds an array of type SiteMapNode to the collection. |
Add |
Adds the nodes in the specified SiteMapNodeCollection to the current collection. |
Clear() |
Removes all items from the collection. |
Contains(Site |
Determines whether the collection contains a specific SiteMapNode object. |
Copy |
Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Retrieves the SiteMapDataSourceView object that is associated with the nodes in the current collection. |
Get |
Retrieves a reference to an enumerator object, which is used to iterate over the collection. |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Retrieves the SiteMapHierarchicalDataSourceView object that is associated with the nodes in the current collection. |
Get |
Returns a hierarchical data item for the specified enumerated item. |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Index |
Searches for the specified SiteMapNode object, and then returns the zero-based index of the first occurrence within the entire collection. |
Insert(Int32, Site |
Inserts the specified SiteMapNode object into the collection at the specified index. |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
On |
Performs additional custom processes when validating a value. |
Read |
Returns a read-only collection that contains the nodes in the specified SiteMapNodeCollection collection. |
Remove(Site |
Removes the specified SiteMapNode object from the collection. |
Remove |
Removes the SiteMapNode object at the specified index of the SiteMapNodeCollection collection. |
To |
Returns a string that represents the current object. (Inherited from Object) |
ICollection. |
Copies the elements of the ICollection interface to an array, starting at a particular array index. This class cannot be inherited. |
ICollection. |
Gets the number of elements that are contained in the ICollection interface. This class cannot be inherited. |
ICollection. |
Gets a |
ICollection. |
Gets an object that can be used to synchronize access to the ICollection interface. This class cannot be inherited. |
IEnumerable. |
Returns an enumerator that iterates through a collection. For a description of this member, see GetEnumerator(). |
IHierarchical |
Returns a hierarchical data item for the specified enumerated item. For a description of this member, see GetHierarchyData(Object). |
IList. |
Adds an item to the collection in the IList interface. For a description of this member, see Add(Object). |
IList. |
Removes all items from the collection in the IList interface. For a description of this member, see Clear(). |
IList. |
Determines whether the collection in the IList interface contains the specified Boolean value. |
IList. |
Determines the index of the specific item in the collection that is returned by the IList interface. For a description of this member, see IndexOf(Object). |
IList. |
Inserts an item into the collection in the IList interface at the specified index. For a description of this member, see Insert(Int32, Object). |
IList. |
Gets a |
IList. |
Gets a |
IList. |
Gets the IList element at the specified index. |
IList. |
Removes the first occurrence of a specified object from the collection in the IList interface. For a description of this member, see Remove(Object). |
IList. |
Removes the IList item at the specified index. For a description of this member, see RemoveAt(Int32). |
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
Of |
Filters the elements of an IEnumerable based on a specified type. |
As |
Enables parallelization of a query. |
As |
Converts an IEnumerable to an IQueryable. |
Продукт | Версії |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Відгук про .NET
.NET – це проект із відкритим кодом. Виберіть посилання, щоб надати відгук: