Aracılığıyla paylaş


SiteMapNodeCollection Oluşturucular

Tanım

SiteMapNodeCollection sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

Name Description
SiteMapNodeCollection()

Sınıfının varsayılan örneği olan yeni bir örneğini SiteMapNodeCollection başlatır.

SiteMapNodeCollection(Int32)

Belirtilen ilk kapasiteye sahip sınıfın SiteMapNodeCollection yeni bir örneğini başlatır.

SiteMapNodeCollection(SiteMapNode)

sınıfının yeni bir örneğini SiteMapNodeCollection başlatır ve nesnesini koleksiyonun InnerList özelliğine eklerSiteMapNode.

SiteMapNodeCollection(SiteMapNode[])

sınıfının yeni bir örneğini SiteMapNodeCollection başlatır ve türü SiteMapNode dizisini koleksiyonun özelliğine InnerList ekler.

SiteMapNodeCollection(SiteMapNodeCollection)

Sınıfının yeni bir örneğini SiteMapNodeCollection başlatır ve belirtilen SiteMapNodeCollection koleksiyonun tüm liste öğelerini koleksiyonun özelliğine InnerList ekler.

SiteMapNodeCollection()

Sınıfının varsayılan örneği olan yeni bir örneğini SiteMapNodeCollection başlatır.

public:
 SiteMapNodeCollection();
public SiteMapNodeCollection();
Public Sub New ()

Örnekler

Aşağıdaki kod örneği, oluşturucuyu SiteMapNodeCollection kullanarak yeni SiteMapNodeCollection bir koleksiyon oluşturmayı ve ardından yöntemiyle Add öğesine öğe SiteMapNodeCollection eklemeyi gösterir.

// 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

Açıklamalar

Boş SiteMapNodeCollection bir koleksiyon oluşturmak için oluşturucuyu SiteMapNodeCollection kullanın. , AddRangeveya Insert yöntemini kullanarak Addöğesine SiteMapNodeCollection öğe ekleyebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır

SiteMapNodeCollection(Int32)

Belirtilen ilk kapasiteye sahip sınıfın SiteMapNodeCollection yeni bir örneğini başlatır.

public:
 SiteMapNodeCollection(int capacity);
public SiteMapNodeCollection(int capacity);
new System.Web.SiteMapNodeCollection : int -> System.Web.SiteMapNodeCollection
Public Sub New (capacity As Integer)

Parametreler

capacity
Int32

öğesinin SiteMapNodeCollectionilk kapasitesi.

Açıklamalar

Belirtilen ilk kapasiteye SiteMapNodeCollection sahip bir SiteMapNodeCollection koleksiyon oluşturmak için oluşturucuyu kullanın.

Ayrıca bkz.

Şunlara uygulanır

SiteMapNodeCollection(SiteMapNode)

sınıfının yeni bir örneğini SiteMapNodeCollection başlatır ve nesnesini koleksiyonun InnerList özelliğine eklerSiteMapNode.

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)

Parametreler

value
SiteMapNode

öğesine eklemek için A SiteMapNodeSiteMapNodeCollection.

Özel durumlar

value, null'e eşittir.

Örnekler

Aşağıdaki kod örneği, tek bir SiteMapNodeCollection ilk SiteMapNode nesneyle koleksiyon oluşturmayı ve ardından yöntemini kullanarak nesnelerden birini SiteMapNodeCollectionSiteMapNode ekleme işlemini AddRange gösterir. Tek tek SiteMapNode nesneler salt okunur olsa bile öğesini değiştirebilirsinizSiteMapNodeCollection.


// 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

Açıklamalar

Tek bir ilk SiteMapNode nesneyle koleksiyon SiteMapNodeCollection oluşturmak için oluşturucuyu SiteMapNodeCollection kullanın. , AddRangeveya Insert yöntemini kullanarak Addöğesine SiteMapNodeCollection öğe ekleyebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır

SiteMapNodeCollection(SiteMapNode[])

sınıfının yeni bir örneğini SiteMapNodeCollection başlatır ve türü SiteMapNode dizisini koleksiyonun özelliğine InnerList ekler.

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())

Parametreler

value
SiteMapNode[]

öğesine eklenecek türde SiteMapNode bir SiteMapNodeCollectiondizi.

Özel durumlar

value, null'e eşittir.

Açıklamalar

Oluşturucunun SiteMapNodeCollection kullanılması, oluşturucuyu SiteMapNodeCollection çağırmaya ve yöntemiyle koleksiyona SiteMapNodeCollection öğe eklemeye AddRange eşdeğerdir.

Ayrıca bkz.

Şunlara uygulanır

SiteMapNodeCollection(SiteMapNodeCollection)

Sınıfının yeni bir örneğini SiteMapNodeCollection başlatır ve belirtilen SiteMapNodeCollection koleksiyonun tüm liste öğelerini koleksiyonun özelliğine InnerList ekler.

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)

Parametreler

value
SiteMapNodeCollection

SiteMapNodeCollection Geçerli SiteMapNodeCollectionöğesine eklenecek öğesini içeren SiteMapNode bir.

Özel durumlar

value, null'e eşittir.

Örnekler

Aşağıdaki kod örneği, temel olarak başka SiteMapNodeCollection bir SiteMapNodeCollection nesne kullanarak bir koleksiyonun SiteMapNode nasıl oluşturulacağını gösterir. SiteMapNode.GetAllNodes yöntemi, özelliği döndürdüğünde IsReadOnlytruealgılanan salt SiteMapNodeCollectionokunur bir döndürür. Salt SiteMapNodeCollection okunur kullanılarak yeni SiteMapNodeCollection bir oluşturulur ve Add ve Remove yöntemleri başarıyla çağrılabilir.

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

Açıklamalar

Oluşturucunun SiteMapNodeCollection kullanılması, oluşturucuyu SiteMapNodeCollection çağırmaya ve yöntemiyle koleksiyona SiteMapNodeCollection öğe eklemeye AddRange eşdeğerdir.

Şunlara uygulanır