SiteMapNodeCollection Construtores
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Inicializa uma nova instância da SiteMapNodeCollection classe.
Sobrecargas
| Name | Description |
|---|---|
| SiteMapNodeCollection() |
Inicializa uma nova instância da SiteMapNodeCollection classe, que é a instância padrão. |
| SiteMapNodeCollection(Int32) |
Inicializa uma nova instância da SiteMapNodeCollection classe com a capacidade inicial especificada. |
| SiteMapNodeCollection(SiteMapNode) |
Inicializa uma nova instância da SiteMapNodeCollection classe e adiciona o SiteMapNode objeto à InnerList propriedade da coleção. |
| SiteMapNodeCollection(SiteMapNode[]) |
Inicializa uma nova instância da SiteMapNodeCollection classe e adiciona o array de tipo SiteMapNode à InnerList propriedade da coleção. |
| SiteMapNodeCollection(SiteMapNodeCollection) |
Inicializa uma nova instância da SiteMapNodeCollection classe e adiciona todos os itens da lista da coleção especificada SiteMapNodeCollection à InnerList propriedade da coleção. |
SiteMapNodeCollection()
Inicializa uma nova instância da SiteMapNodeCollection classe, que é a instância padrão.
public:
SiteMapNodeCollection();
public SiteMapNodeCollection();
Public Sub New ()
Exemplos
O exemplo de código seguinte demonstra como usar o SiteMapNodeCollection construtor para criar uma nova SiteMapNodeCollection coleção e depois adicionar elementos ao SiteMapNodeCollection com o Add método.
// 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
Observações
Use o SiteMapNodeCollection construtor para criar uma coleção vazia SiteMapNodeCollection . Pode adicionar elementos ao SiteMapNodeCollection usando o Addmétodo , AddRange, ou Insert .
Ver também
Aplica-se a
SiteMapNodeCollection(Int32)
Inicializa uma nova instância da SiteMapNodeCollection classe com a capacidade inicial especificada.
public:
SiteMapNodeCollection(int capacity);
public SiteMapNodeCollection(int capacity);
new System.Web.SiteMapNodeCollection : int -> System.Web.SiteMapNodeCollection
Public Sub New (capacity As Integer)
Parâmetros
- capacity
- Int32
A capacidade inicial do SiteMapNodeCollection.
Observações
Use o SiteMapNodeCollection construtor para criar uma SiteMapNodeCollection coleção com a capacidade inicial especificada.
Ver também
Aplica-se a
SiteMapNodeCollection(SiteMapNode)
Inicializa uma nova instância da SiteMapNodeCollection classe e adiciona o SiteMapNode objeto à InnerList propriedade da coleção.
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)
Parâmetros
- value
- SiteMapNode
A SiteMapNode para acrescentar ao SiteMapNodeCollection.
Exceções
value é null.
Exemplos
O exemplo de código seguinte demonstra como criar uma SiteMapNodeCollection coleção com um único objeto inicial SiteMapNode e depois adicionar um SiteMapNodeCollection número de SiteMapNode objetos a ela usando o AddRange método. Pode modificar o SiteMapNodeCollection, mesmo que os objetos individuais SiteMapNode possam ser apenas de leitura.
// 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
Observações
Use o SiteMapNodeCollection construtor para criar uma SiteMapNodeCollection coleção com um único objeto inicial SiteMapNode . Pode adicionar elementos ao SiteMapNodeCollection usando o Addmétodo , AddRange, ou Insert .
Ver também
Aplica-se a
SiteMapNodeCollection(SiteMapNode[])
Inicializa uma nova instância da SiteMapNodeCollection classe e adiciona o array de tipo SiteMapNode à InnerList propriedade da coleção.
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())
Parâmetros
- value
- SiteMapNode[]
Um array de tipo SiteMapNode para adicionar ao SiteMapNodeCollection.
Exceções
value é null.
Observações
Usar o SiteMapNodeCollection construtor é equivalente a chamar o SiteMapNodeCollection construtor e adicionar elementos à SiteMapNodeCollection coleção com o AddRange método.
Ver também
Aplica-se a
SiteMapNodeCollection(SiteMapNodeCollection)
Inicializa uma nova instância da SiteMapNodeCollection classe e adiciona todos os itens da lista da coleção especificada SiteMapNodeCollection à InnerList propriedade da coleção.
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)
Parâmetros
- value
- SiteMapNodeCollection
A SiteMapNodeCollection que contém o SiteMapNode para adicionar à corrente SiteMapNodeCollection.
Exceções
value é null.
Exemplos
O exemplo de código seguinte demonstra como criar uma SiteMapNodeCollection coleção usando outra SiteMapNodeCollection de SiteMapNode objetos como base. O SiteMapNode.GetAllNodes método devolve um somente SiteMapNodeCollectionleitura , que é detetado quando a IsReadOnly propriedade devolve true. Um novo SiteMapNodeCollection é criado usando o somente SiteMapNodeCollection leitura e os Add métodos e Remove podem ser chamados com sucesso.
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
Observações
Usar o SiteMapNodeCollection construtor é equivalente a chamar o SiteMapNodeCollection construtor e adicionar elementos à SiteMapNodeCollection coleção com o AddRange método.