SiteMapNode.Clone 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 노드의 복사본인 새 노드를 만듭니다.
오버로드
| Name | Description |
|---|---|
| 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 속성이 복사됩니다.
Roles 및 Attributes 컬렉션은 새 컬렉션에 복사됩니다. 상위 노드와 자식 노드는 복제되지 않습니다.
추가 정보
적용 대상
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 경우 메서드는 trueClone모든 직접 상위 노드를 재귀적으로 복제하고 현재 복제된 노드와 연결합니다. 자식 노드는 복제되지 않습니다.
Roles 및 Attributes 컬렉션은 새 컬렉션에 적용됩니다.