SiteMapNodeCollection Конструкторы
Определение
Инициализирует новый экземпляр класса SiteMapNodeCollection.Initializes a new instance of the SiteMapNodeCollection class.
Перегрузки
SiteMapNodeCollection() |
Выполняет инициализацию нового экземпляра класса SiteMapNodeCollection, заданного по умолчанию.Initializes a new instance of the SiteMapNodeCollection class, which is the default instance. |
SiteMapNodeCollection(Int32) |
Выполняет инициализацию нового экземпляра класса SiteMapNodeCollection с указанными начальными возможностями.Initializes a new instance of the SiteMapNodeCollection class with the specified initial capacity. |
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(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. |
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()
Выполняет инициализацию нового экземпляра класса SiteMapNodeCollection, заданного по умолчанию.Initializes a new instance of the SiteMapNodeCollection class, which is the default instance.
public:
SiteMapNodeCollection();
public SiteMapNodeCollection ();
Public Sub New ()
Примеры
В следующем примере кода показано, как использовать SiteMapNodeCollection конструктор для создания новой SiteMapNodeCollection коллекции, а затем добавлять элементы в SiteMapNodeCollection метод с помощью Add метода.The following code example demonstrates how to use the SiteMapNodeCollection constructor to create a new SiteMapNodeCollection collection, and then add elements to the SiteMapNodeCollection with the Add method.
// The LoadSiteMapData() method loads site navigation
// data from persistent storage into a DataTable.
DataTable siteMap = LoadSiteMapData();
// Create a SiteMapNodeCollection.
SiteMapNodeCollection nodes = new SiteMapNodeCollection();
// Create a SiteMapNode and add it to the collection.
SiteMapNode tempNode;
DataRow row;
int index = 0;
while (index < siteMap.Rows.Count)
{
row = siteMap.Rows[index];
// Create a node based on the data in the DataRow.
tempNode = new SiteMapNode(SiteMap.Provider,
row["Key"].ToString(),
row["Url"].ToString());
// Add the node to the collection.
nodes.Add(tempNode);
++index;
}
' The LoadSiteMapData() Function loads site navigation
' data from persistent storage into a DataTable.
Dim siteMapData As DataTable
siteMapData = LoadSiteMapData()
' Create a SiteMapNodeCollection.
Dim nodes As New SiteMapNodeCollection()
' Create a SiteMapNode and add it to the collection.
Dim tempNode As SiteMapNode
Dim row As DataRow
Dim index As Integer
index = 0
While (index < siteMapData.Rows.Count)
row = siteMapData.Rows(index)
' Create a node based on the data in the DataRow.
tempNode = New SiteMapNode(SiteMap.Provider, row("Key").ToString(), row("Url").ToString())
' Add the node to the collection.
nodes.Add(tempNode)
index = index + 1
End While
Комментарии
Используйте SiteMapNodeCollection конструктор для создания пустой SiteMapNodeCollection коллекции.Use the SiteMapNodeCollection constructor to create an empty SiteMapNodeCollection collection. Элементы можно добавлять в SiteMapNodeCollection с помощью Add AddRange метода, или Insert .You can add elements to the SiteMapNodeCollection using the Add, AddRange, or Insert method.
См. также раздел
Применяется к
SiteMapNodeCollection(Int32)
Выполняет инициализацию нового экземпляра класса SiteMapNodeCollection с указанными начальными возможностями.Initializes a new instance of the SiteMapNodeCollection class with the specified initial capacity.
public:
SiteMapNodeCollection(int capacity);
public SiteMapNodeCollection (int capacity);
new System.Web.SiteMapNodeCollection : int -> System.Web.SiteMapNodeCollection
Public Sub New (capacity As Integer)
Параметры
- capacity
- Int32
Начальные возможности коллекции SiteMapNodeCollection.The initial capacity of the SiteMapNodeCollection.
Комментарии
Используйте SiteMapNodeCollection конструктор для создания SiteMapNodeCollection коллекции с указанной начальной емкостью.Use the SiteMapNodeCollection constructor to create a SiteMapNodeCollection collection with the specified initial capacity.
См. также раздел
Применяется к
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.
public:
SiteMapNodeCollection(System::Web::SiteMapNode ^ value);
public SiteMapNodeCollection (System.Web.SiteMapNode value);
new System.Web.SiteMapNodeCollection : System.Web.SiteMapNode -> System.Web.SiteMapNodeCollection
Public Sub New (value As SiteMapNode)
Параметры
- value
- SiteMapNode
Таблица SiteMapNode, добавляемая в представление SiteMapNodeCollection.A SiteMapNode to add to the SiteMapNodeCollection.
Исключения
value
имеет значение null
.value
is null
.
Примеры
В следующем примере кода показано, как создать SiteMapNodeCollection коллекцию с одним начальным SiteMapNode объектом, а затем добавить к SiteMapNodeCollection SiteMapNode нему объекты с помощью AddRange метода.The following code example demonstrates how to create a SiteMapNodeCollection collection with a single initial SiteMapNode object, and then add a SiteMapNodeCollection of SiteMapNode objects to it using the AddRange method. Можно изменить SiteMapNodeCollection , даже если отдельные SiteMapNode объекты могут быть доступны только для чтения.You can modify the SiteMapNodeCollection, even though the individual SiteMapNode objects might be read-only.
// 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 конструктор для создания SiteMapNodeCollection коллекции с одним начальным SiteMapNode объектом.Use the SiteMapNodeCollection constructor to create a SiteMapNodeCollection collection with a single initial SiteMapNode object. Элементы можно добавлять в SiteMapNodeCollection с помощью Add AddRange метода, или Insert .You can add elements to the SiteMapNodeCollection using the Add, AddRange, or Insert method.
См. также раздел
Применяется к
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.
public:
SiteMapNodeCollection(cli::array <System::Web::SiteMapNode ^> ^ value);
public SiteMapNodeCollection (System.Web.SiteMapNode[] value);
new System.Web.SiteMapNodeCollection : System.Web.SiteMapNode[] -> System.Web.SiteMapNodeCollection
Public Sub New (value As SiteMapNode())
Параметры
- value
- SiteMapNode[]
Массив типа SiteMapNode, который необходимо добавить в коллекцию SiteMapNodeCollection.An array of type SiteMapNode to add to the SiteMapNodeCollection.
Исключения
value
имеет значение null
.value
is null
.
Комментарии
Использование SiteMapNodeCollection конструктора эквивалентно вызову SiteMapNodeCollection конструктора и добавлению элементов в SiteMapNodeCollection коллекцию с помощью AddRange метода.Using the SiteMapNodeCollection constructor is equivalent to calling the SiteMapNodeCollection constructor and adding elements to the SiteMapNodeCollection collection with the AddRange method.
См. также раздел
Применяется к
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.
public:
SiteMapNodeCollection(System::Web::SiteMapNodeCollection ^ value);
public SiteMapNodeCollection (System.Web.SiteMapNodeCollection value);
new System.Web.SiteMapNodeCollection : System.Web.SiteMapNodeCollection -> System.Web.SiteMapNodeCollection
Public Sub New (value As SiteMapNodeCollection)
Параметры
- value
- SiteMapNodeCollection
Объект SiteMapNodeCollection, содержащий объект SiteMapNode для добавления в текущую коллекцию SiteMapNodeCollection.A SiteMapNodeCollection that contains the SiteMapNode to add to the current SiteMapNodeCollection.
Исключения
value
имеет значение null
.value
is null
.
Примеры
В следующем примере кода показано, как создать SiteMapNodeCollection коллекцию с использованием другого SiteMapNodeCollection SiteMapNode объекта в качестве базового.The following code example demonstrates how to create a SiteMapNodeCollection collection using another SiteMapNodeCollection of SiteMapNode objects as a base. SiteMapNode.GetAllNodesМетод возвращает доступное только для чтения значение SiteMapNodeCollection , которое определяется при IsReadOnly возврате свойства true
.The SiteMapNode.GetAllNodes method returns a read-only SiteMapNodeCollection, which is detected when the IsReadOnly property returns true
. Новый объект SiteMapNodeCollection создается с использованием только для чтения SiteMapNodeCollection , а Add методы и Remove могут быть успешно вызваны.A new SiteMapNodeCollection is created using the read-only SiteMapNodeCollection and the Add and Remove methods can be called successfully.
SiteMapNodeCollection siteNodes = SiteMap.RootNode.GetAllNodes();
if ( siteNodes.IsReadOnly ||
siteNodes.IsFixedSize )
{
Response.Write("Collection is read-only or has fixed size.<BR>");
// Create a new, modifiable collection from the existing one.
SiteMapNodeCollection modifiableCollection =
new SiteMapNodeCollection(siteNodes);
// The MoveNode example method moves a node from position one to
// the last position in the collection.
MoveNode(modifiableCollection);
}
else {
MoveNode(siteNodes);
}
Dim siteNodes As SiteMapNodeCollection
siteNodes = SiteMap.RootNode.GetAllNodes()
If siteNodes.IsReadOnly Or siteNodes.IsFixedSize Then
Response.Write("Collection is read-only or has fixed size.<BR>")
' Create a new, modifiable collection from the existing one.
Dim modifiableCollection As SiteMapNodeCollection
modifiableCollection = New SiteMapNodeCollection(siteNodes)
' The MoveNode example method moves a node from position one to
' the last position in the collection.
MoveNode(modifiableCollection)
Else
MoveNode(siteNodes)
End If
Комментарии
Использование SiteMapNodeCollection конструктора эквивалентно вызову SiteMapNodeCollection конструктора и добавлению элементов в SiteMapNodeCollection коллекцию с помощью AddRange метода.Using the SiteMapNodeCollection constructor is equivalent to calling the SiteMapNodeCollection constructor and adding elements to the SiteMapNodeCollection collection with the AddRange method.