SiteMapProvider.GetChildNodes(SiteMapNode) 메서드

정의

파생 클래스에서 재정의되면 특정 SiteMapNode의 자식 노드를 검색합니다.

public:
 abstract System::Web::SiteMapNodeCollection ^ GetChildNodes(System::Web::SiteMapNode ^ node);
public abstract System.Web.SiteMapNodeCollection GetChildNodes (System.Web.SiteMapNode node);
abstract member GetChildNodes : System.Web.SiteMapNode -> System.Web.SiteMapNodeCollection
Public MustOverride Function GetChildNodes (node As SiteMapNode) As SiteMapNodeCollection

매개 변수

node
SiteMapNode

모든 자식 노드를 검색할 SiteMapNode입니다.

반환

SiteMapNodeCollection

지정된 SiteMapNodeCollection의 직접 자식 노드가 들어 있는 읽기 전용 SiteMapNode이거나, 그렇지 않고 자식 노드가 없으면 null 또는 빈 컬렉션입니다.

예제

다음 코드 예제를 구현 하는 방법에 설명 합니다 GetChildNodes 메서드를 구현 하는 클래스에서 SiteMapProvider 클래스입니다. 합니다 SimpleTextSiteMapProvider 계층적 부모/자식 관계를 하나에 저장 Hashtable 개체와 모든 SiteMapNode 다른 개체입니다. 합니다 GetChildNodes 둘 다를 사용 하 여 역방향 조회를 수행 하는 메서드 ArrayList 개체입니다.

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 SiteMapProvider 클래스입니다.

// Implement the GetChildNodes method.
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
{
  SiteMapNodeCollection children = new SiteMapNodeCollection();
  // Iterate through the ArrayList and find all nodes that have the specified node as a parent.
  lock (this)
  {
    for (int i = 0; i < childParentRelationship.Count; i++)
    {

      string nodeUrl = ((DictionaryEntry)childParentRelationship[i]).Key as string;

      SiteMapNode parent = GetNode(childParentRelationship, nodeUrl);

      if (parent != null && node.Url == parent.Url)
      {
        // The SiteMapNode with the Url that corresponds to nodeUrl
        // is a child of the specified node. Get the SiteMapNode for
        // the nodeUrl.
        SiteMapNode child = FindSiteMapNode(nodeUrl);
        if (child != null)
        {
          children.Add(child as SiteMapNode);
        }
        else
        {
          throw new Exception("ArrayLists not in sync.");
        }
      }
    }
  }
  return children;
}
protected override SiteMapNode GetRootNodeCore()
{
  return RootNode;
}
// Implement the GetParentNode method.
public override SiteMapNode GetParentNode(SiteMapNode node)
{
  // Check the childParentRelationship table and find the parent of the current node.
  // If there is no parent, the current node is the RootNode.
  SiteMapNode parent = null;
  lock (this)
  {
    // Get the Value of the node in childParentRelationship
    parent = GetNode(childParentRelationship, node.Url);
  }
  return parent;
}
' Implement the GetChildNodes method.
Public Overrides Function GetChildNodes(ByVal node As SiteMapNode) As SiteMapNodeCollection
  Dim children As New SiteMapNodeCollection()
  ' Iterate through the ArrayList and find all nodes that have the specified node as a parent.
  SyncLock Me
    Dim i As Integer
    For i = 0 To childParentRelationship.Count - 1

      Dim de As DictionaryEntry = CType(childParentRelationship(i), DictionaryEntry)
      Dim nodeUrl As String = CType(de.Key, String)

      Dim parent As SiteMapNode = GetNode(childParentRelationship, nodeUrl)

      If Not (parent Is Nothing) AndAlso node.Url = parent.Url Then
        ' The SiteMapNode with the Url that corresponds to nodeUrl
        ' is a child of the specified node. Get the SiteMapNode for
        ' the nodeUrl.
        Dim child As SiteMapNode = FindSiteMapNode(nodeUrl)
        If Not (child Is Nothing) Then
          children.Add(CType(child, SiteMapNode))
        Else
          Throw New Exception("ArrayLists not in sync.")
        End If
      End If
    Next i
  End SyncLock
  Return children
End Function 'GetChildNodes

Protected Overrides Function GetRootNodeCore() As SiteMapNode
  Return RootNode
End Function ' GetRootNodeCore()

' Implement the GetParentNode method.
Public Overrides Function GetParentNode(ByVal node As SiteMapNode) As SiteMapNode
  ' Check the childParentRelationship table and find the parent of the current node.
  ' If there is no parent, the current node is the RootNode.
  Dim parent As SiteMapNode = Nothing
  SyncLock Me
    ' Get the Value of the node in childParentRelationship
    parent = GetNode(childParentRelationship, node.Url)
  End SyncLock
  Return parent
End Function 'GetParentNode

설명

파생 된 클래스는 SiteMapProvider 추상 클래스를 구현 해야 GetChildNodes 메서드.

구현자 참고

재정의 하는 경우는 GetChildNodes(SiteMapNode) 파생된 클래스에서 메서드 자식 노드의 보안 트리밍이 수행 하는 반환 된 컬렉션을 읽기 전용인 지를 확인 해야 합니다. 컬렉션에 지정 된 직계 자식만 node합니다.

적용 대상

추가 정보