SiteMapNode.Clone 메서드

정의

현재 노드의 복사본인 새 노드를 만듭니다.

오버로드

Clone()

현재 노드의 복사본인 새 노드를 만듭니다.

Clone(Boolean)

현재 노드의 복사본인 새 복사본을 만들고 필요에 따라 현재 노드의 모든 부모 및 상위 노드를 복제합니다.

Clone()

현재 노드의 복사본인 새 노드를 만듭니다.

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

반환

현재 노드의 복사본인 새 노드입니다.

설명

호출 된 Clone 로 설정 하는 매개 변수를 사용 하 여 메서드 false합니다. 공급자 Title, UrlDescription, 및 Key 속성이 복사 됩니다. 합니다 RolesAttributes 컬렉션 새 컬렉션에 복사 됩니다. 상위 및 하위 노드를 복제 되지 않습니다.

추가 정보

적용 대상

Clone(Boolean)

현재 노드의 복사본인 새 복사본을 만들고 필요에 따라 현재 노드의 모든 부모 및 상위 노드를 복제합니다.

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

매개 변수

cloneParentNodes
Boolean

현재 노드의 모든 부모 및 상위 노드를 복제하려면 true이고, 그렇지 않으면 false입니다.

반환

현재 노드의 복사본인 새 노드입니다.

예제

다음 코드 예제를 호출 하는 방법에 설명 합니다 Clone 메서드를 현재 노드에서 중복 된 사이트 맵 노드를 만듭니다. ExpandForumPaths 메서드 처리 하도록 등록 된 SiteMapResolve 이벤트입니다. 사용 하 여는 Clone 메서드를 작업 복사본 현재 사이트 맵 노드를 만들고 개인 설정 데이터를 기반으로 하는 특성을 수정 하 고 작업 복사본을 반환 합니다.

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

설명

경우는 cloneParentNodes 매개 변수가 true, Clone 메서드를 재귀적으로 모든 직계 상위 노드를 복제 하 고 현재 복제 된 노드에 연결 합니다. 자식 노드 복제 되지 않습니다.

합니다 RolesAttributes 컬렉션 새 컬렉션에 적용 됩니다.

추가 정보

적용 대상