SiteMapNode.Clone Methode

Definition

Erstellt einen neuen Knoten, der eine Kopie des aktuellen Knotens darstellt.

Überlädt

Clone()

Erstellt einen neuen Knoten, der eine Kopie des aktuellen Knotens darstellt.

Clone(Boolean)

Erstellt eine neue Kopie, die eine Kopie des aktuellen Knotens darstellt, wobei optional alle übergeordneten Knoten und Vorgängerknoten des aktuellen Knotens geklont werden.

Clone()

Erstellt einen neuen Knoten, der eine Kopie des aktuellen Knotens darstellt.

public:
 virtual System::Web::SiteMapNode ^ Clone();
public virtual System.Web.SiteMapNode Clone ();
abstract member Clone : unit -> System.Web.SiteMapNode
override this.Clone : unit -> System.Web.SiteMapNode
Public Overridable Function Clone () As SiteMapNode

Gibt zurück

Ein neuer Knoten, der eine Kopie des aktuellen Knotens darstellt.

Hinweise

Ruft die Clone -Methode auf, wobei der Parameter auf festgelegt ist false. Die Eigenschaften anbieter, Title, Url, Descriptionund Key werden kopiert. Die Roles Sammlungen und Attributes werden in neue Sammlungen kopiert. Vorgänger- und untergeordnete Knoten werden nicht geklont.

Weitere Informationen

Gilt für:

Clone(Boolean)

Erstellt eine neue Kopie, die eine Kopie des aktuellen Knotens darstellt, wobei optional alle übergeordneten Knoten und Vorgängerknoten des aktuellen Knotens geklont werden.

public:
 virtual System::Web::SiteMapNode ^ Clone(bool cloneParentNodes);
public virtual System.Web.SiteMapNode Clone (bool cloneParentNodes);
abstract member Clone : bool -> System.Web.SiteMapNode
override this.Clone : bool -> System.Web.SiteMapNode
Public Overridable Function Clone (cloneParentNodes As Boolean) As SiteMapNode

Parameter

cloneParentNodes
Boolean

true, um alle übergeordneten Knoten und Vorgängerknoten des aktuellen Knotens zu klonen, andernfalls false.

Gibt zurück

Ein neuer Knoten, der eine Kopie des aktuellen Knotens darstellt.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie Die Clone -Methode aufgerufen wird, um einen doppelten Siteübersichtsknoten aus dem aktuellen Knoten zu erstellen. Die ExpandForumPaths -Methode wird registriert, um das SiteMapResolve Ereignis zu behandeln. Sie verwendet die Clone -Methode, um eine Arbeitskopie des aktuellen Siteübersichtsknotens zu erstellen, Attribute basierend auf Personalisierungsdaten zu ändern und die Arbeitskopie zurückzugeben.

private void Page_Load(object sender, EventArgs e)
{
    // The ExpandForumPaths method is called to handle
    // the SiteMapResolve event.
    SiteMap.SiteMapResolve +=
      new SiteMapResolveEventHandler(this.ExpandForumPaths);
}

private SiteMapNode ExpandForumPaths(Object sender, SiteMapResolveEventArgs e)
{
    // The current node represents a Post page in a bulletin board forum.
    // Clone the current node and all of its relevant parents. This
    // returns a site map node that a developer can then
    // walk, modifying each node.Url property in turn.
    // Since the cloned nodes are separate from the underlying
    // site navigation structure, the fixups that are made do not
    // effect the overall site navigation structure.
    SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
    SiteMapNode tempNode = currentNode;

    // Obtain the recent IDs.
    int forumGroupID = GetMostRecentForumGroupID();
    int forumID = GetMostRecentForumID(forumGroupID);
    int postID = GetMostRecentPostID(forumID);

    // The current node, and its parents, can be modified to include
    // dynamic querystring information relevant to the currently
    // executing request.
    if (0 != postID)
    {
        tempNode.Url = tempNode.Url + "?PostID=" + postID.ToString();
    }

    if ((null != (tempNode = tempNode.ParentNode)) &&
        (0 != forumID))
    {
        tempNode.Url = tempNode.Url + "?ForumID=" + forumID.ToString();
    }

    if ((null != (tempNode = tempNode.ParentNode)) &&
        (0 != forumGroupID))
    {
        tempNode.Url = tempNode.Url + "?ForumGroupID=" + forumGroupID.ToString();
    }

    return currentNode;
}
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    ' The ExpandForumPaths method is called to handle
    ' the SiteMapResolve event.
    AddHandler SiteMap.SiteMapResolve, AddressOf Me.ExpandForumPaths

End Sub

Private Function ExpandForumPaths(ByVal sender As Object, ByVal e As SiteMapResolveEventArgs) As SiteMapNode
    ' The current node represents a Post page in a bulletin board forum.
    ' Clone the current node and all of its relevant parents. This
    ' returns a site map node that a developer can then
    ' walk, modifying each node.Url property in turn.
    ' Since the cloned nodes are separate from the underlying
    ' site navigation structure, the fixups that are made do not
    ' effect the overall site navigation structure.
    Dim currentNode As SiteMapNode = SiteMap.CurrentNode.Clone(True)
    Dim tempNode As SiteMapNode = currentNode

    ' Obtain the recent IDs.
    Dim forumGroupID As Integer = GetMostRecentForumGroupID()
    Dim forumID As Integer = GetMostRecentForumID(forumGroupID)
    Dim postID As Integer = GetMostRecentPostID(forumID)

    ' The current node, and its parents, can be modified to include
    ' dynamic querystring information relevant to the currently
    ' executing request.
    If Not (0 = postID) Then
        tempNode.Url = tempNode.Url & "?PostID=" & postID.ToString()
    End If

    tempNode = tempNode.ParentNode
    If Not (0 = forumID) And Not (tempNode Is Nothing) Then
        tempNode.Url = tempNode.Url & "?ForumID=" & forumID.ToString()
    End If

    tempNode = tempNode.ParentNode
    If Not (0 = ForumGroupID) And Not (tempNode Is Nothing) Then
        tempNode.Url = tempNode.Url & "?ForumGroupID=" & forumGroupID.ToString()
    End If

    Return currentNode

End Function

Hinweise

Wenn der cloneParentNodes Parameter ist true, klont die Clone Methode rekursiv alle direkten Vorgängerknoten und ordnet sie dem aktuellen geklonten Knoten zu. Untergeordnete Knoten werden nicht geklont.

Die Roles Auflistungen und Attributes werden auf neue Sammlungen angewendet.

Weitere Informationen

Gilt für: