SiteMapNode 클래스

정의

SiteMap 클래스 및 추상 SiteMapProvider 클래스를 구현하는 클래스에서 설명하는 것 같은 계층적 사이트 맵 구조의 노드를 나타냅니다.

public ref class SiteMapNode : ICloneable, System::Web::UI::IHierarchyData, System::Web::UI::INavigateUIData
public class SiteMapNode : ICloneable, System.Web.UI.IHierarchyData, System.Web.UI.INavigateUIData
type SiteMapNode = class
    interface ICloneable
    interface IHierarchyData
    interface INavigateUIData
Public Class SiteMapNode
Implements ICloneable, IHierarchyData, INavigateUIData
상속
SiteMapNode
구현

예제

이 섹션에는 두 코드 예제가 있습니다. 첫 번째 코드 예제에서는 새 사이트 맵 노드 컬렉션을 만들고 요소를 추가 하는 방법을 보여 줍니다. 두 번째 코드 예제에서는 텍스트 파일에서 사이트 맵 데이터를 로드 하는 방법을 보여 줍니다.

다음 코드 예제를 사용 하는 방법에 설명 합니다 SiteMapNodeCollection 새 생성자 SiteMapNodeCollection 컬렉션을 추가한 다음 요소를 사용 하 여를 Add 메서드.

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

다음 코드 예제에서는 방법을 SimpleTextSiteMapProvider 쉼표로 구분 된 문자열에는 사이트 맵 데이터를 포함 하는 텍스트 파일 구문 분석 합니다. 새 SiteMapNode 개체 파일에서 읽을 수 있는 각 줄에 대 한 클래스의 내부 추적 컬렉션에 추가 됩니다.

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

protected virtual void LoadSiteMapFromStore()
{
  string pathToOpen;

  lock (this)
  {
    // If a root node exists, LoadSiteMapFromStore has already
    // been called, and the method can return.
    if (rootNode != null)
    {
      return;
    }
    else
    {
      pathToOpen = HttpContext.Current.Server.MapPath("~" + "\\" + sourceFilename);

      if (File.Exists(pathToOpen))
      {
        // Open the file to read from.
        using (StreamReader sr = File.OpenText(pathToOpen))
        {

          // Clear the state of the collections and rootNode
          rootNode = null;
          siteMapNodes.Clear();
          childParentRelationship.Clear();

          // Parse the file and build the site map
          string s = "";
          string[] nodeValues = null;
          SiteMapNode temp = null;

          while ((s = sr.ReadLine()) != null)
          {

            // Build the various SiteMapNode objects and add
            // them to the ArrayList collections. The format used
            // is: URL,TITLE,DESCRIPTION,PARENTURL

            nodeValues = s.Split(',');

            temp = new SiteMapNode(this,
                HttpRuntime.AppDomainAppVirtualPath + "/" + nodeValues[0],
                HttpRuntime.AppDomainAppVirtualPath + "/" + nodeValues[0],
                nodeValues[1],
                nodeValues[2]);

            // Is this a root node yet?
            if (null == rootNode &&
                string.IsNullOrEmpty(nodeValues[3]))
            {
              rootNode = temp;
            }

          // If not the root node, add the node to the various collections.
            else
            {
              siteMapNodes.Add(new DictionaryEntry(temp.Url, temp));
              // The parent node has already been added to the collection.
              SiteMapNode parentNode =
                       FindSiteMapNode(HttpRuntime.AppDomainAppVirtualPath + "/" + nodeValues[3]);
              if (parentNode != null)
              {
                childParentRelationship.Add(new DictionaryEntry(temp.Url, parentNode));
              }
              else
              {
                throw new Exception("Parent node not found for current node.");
              }
            }
          }
        }
      }
      else
      {
        throw new Exception("File not found");
      }
    }
  }
  return;
}
  Protected Overridable Sub LoadSiteMapFromStore()
    Dim pathToOpen As String
    SyncLock Me
      ' If a root node exists, LoadSiteMapFromStore has already
      ' been called, and the method can return.
      If Not (aRootNode Is Nothing) Then
        Return
      Else
        pathToOpen = HttpContext.Current.Server.MapPath("~" & "\\" & sourceFilename)
        If File.Exists(pathToOpen) Then
          ' Open the file to read from.
          Dim sr As StreamReader = File.OpenText(pathToOpen)
          Try

            ' Clear the state of the collections and aRootNode
            aRootNode = Nothing
            siteMapNodes.Clear()
            childParentRelationship.Clear()

            ' Parse the file and build the site map
            Dim s As String = ""
            Dim nodeValues As String() = Nothing
            Dim temp As SiteMapNode = Nothing

            Do
              s = sr.ReadLine()

              If Not s Is Nothing Then
                ' Build the various SiteMapNode objects and add
                ' them to the ArrayList collections. The format used
                ' is: URL,TITLE,DESCRIPTION,PARENTURL
                nodeValues = s.Split(","c)

                temp = New SiteMapNode(Me, _
                    HttpRuntime.AppDomainAppVirtualPath & "/" & nodeValues(0), _
                    HttpRuntime.AppDomainAppVirtualPath & "/" & nodeValues(0), _
                    nodeValues(1), _
                    nodeValues(2))

                ' Is this a root node yet?
                If aRootNode Is Nothing AndAlso _
                  (nodeValues(3) Is Nothing OrElse _
                   nodeValues(3) = String.Empty) Then
                  aRootNode = temp

                  ' If not the root node, add the node to the various collections.
                Else

                  siteMapNodes.Add(New DictionaryEntry(temp.Url, temp))

                  ' The parent node has already been added to the collection.
                  Dim parentNode As SiteMapNode = _
                      FindSiteMapNode(HttpRuntime.AppDomainAppVirtualPath & "/" & nodeValues(3))

                  If Not (parentNode Is Nothing) Then
                    childParentRelationship.Add(New DictionaryEntry(temp.Url, parentNode))
                  Else
                    Throw New Exception("Parent node not found for current node.")
                  End If
                End If
              End If
            Loop Until s Is Nothing
          Finally
            sr.Close()
          End Try
        Else
          Throw New Exception("File not found")
        End If
      End If
    End SyncLock
    Return
  End Sub
End Class

설명

SiteMapNode 개체는 사이트 맵 구조에서 웹 사이트 페이지를 나타냅니다. SiteMapNode 개체는 하나 이상의 사이트 맵 공급자를 사용하여 런타임 시 정적 SiteMap 클래스에 의해 로드되어 영구 스토리지에 메모리로 로드됩니다. SiteMapNode 개체를 래핑합니다 합니다 SiteMapNodeItem 와 같은 웹 서버 컨트롤에서 사용 하기 위해 클래스는 SiteMapPath 제어 합니다.

합니다 SiteMapNode 클래스와 같은 페이지를 설명 하는 속성을 포함 하 여 웹 사이트의 단일 페이지에 설명 하는 데 사용 되는 몇 가지 속성을 포함 합니다 Url, Title, 및 Description 속성입니다. 반면를 Url 속성을 사용 합니다 XmlSiteMapProvider 공급자 노드를 추적 하는 데 사용 하는 내부 컬렉션의 조회 키로 ASP.NET에 대 한 기본 사이트 맵 공급자가 클래스를 SiteMapNode 클래스는 기본 지원 Key 노드를 추적 하려면 사이트 맵 공급자가 사용할 수 있는 속성입니다. 또한는 Url 하이퍼링크 된 탐색 구조 내에서 페이지를 렌더링 하 속성은 탐색 컨트롤에서 사용 합니다. 합니다 Title 속성에 대 한 친숙 한 이름인는 SiteMapNode, 웹 폼의 HTML 제목으로 동일한 경우가 및 탐색 컨트롤에서 간단한 레이블을 렌더링 하는 데 사용 됩니다. 마지막으로 한 NameValueCollection 컬렉션 추가 Attributes 특성을 사용 하는 사이트 맵 공급자를 사용할 수 SiteMapNode 개체에는 있지만 자료에서 사용할 수 없는 추가 속성이 필요한 SiteMapNode 클래스입니다.

생성자

SiteMapNode(SiteMapProvider, String)

노드에서 나타내는 페이지를 식별하는 지정된 key와 노드를 관리하는 사이트 맵 공급자를 사용하여 SiteMapNode 클래스의 새 인스턴스를 초기화합니다.

SiteMapNode(SiteMapProvider, String, String)

지정된 URL, 노드에서 나타내는 페이지를 식별하는 key 및 노드를 관리하는 사이트 맵 공급자를 사용하여 SiteMapNode 클래스의 새 인스턴스를 초기화합니다.

SiteMapNode(SiteMapProvider, String, String, String)

지정된 URL, 노드에서 나타내는 페이지를 식별하는 key, 제목 및 노드를 관리하는 사이트 맵 공급자를 사용하여 SiteMapNode 클래스의 새 인스턴스를 초기화합니다.

SiteMapNode(SiteMapProvider, String, String, String, String)

지정된 URL, 노드에서 나타내는 페이지를 식별하는 key, 제목과 설명 및 노드를 관리하는 사이트 맵 공급자를 사용하여 SiteMapNode 클래스의 새 인스턴스를 초기화합니다.

SiteMapNode(SiteMapProvider, String, String, String, String, IList, NameValueCollection, NameValueCollection, String)

노드, URL, 제목, 설명, 역할, 추가 특성 및 지역화를 위한 명시적 및 암시적 리소스 키를 관리하는 지정된 사이트 맵 공급자를 사용하여 SiteMapNode 클래스의 새 인스턴스를 초기화합니다.

속성

Attributes

SiteMapNode 클래스에 대해 정의된 강력한 형식의 속성 이외에 추가 특성 컬렉션을 가져오거나 설정합니다.

ChildNodes

관련된 SiteMapNode 공급자에서 현재 SiteMapProvider 개체의 모든 자식 노드를 가져오거나 설정합니다.

Description

SiteMapNode에 대한 설명을 가져오거나 설정합니다.

HasChildNodes

현재 SiteMapNode에 자식 노드가 있는지 여부를 나타내는 값을 가져옵니다.

Item[String]

지정된 키를 기반으로 Attributes 컬렉션의 사용자 지정 특성이나 리소스 문자열을 가져오거나 설정합니다.

Key

사이트 맵 노드에 대한 조회 키를 나타내는 문자열을 가져옵니다.

NextSibling

현재와 동일한 계층 구조 수준에서 SiteMapNode 속성(있는 경우)에 상대적인 다음 ParentNode 노드를 가져옵니다.

ParentNode

현재 노드의 부모인 SiteMapNode 개체를 가져오거나 설정합니다.

PreviousSibling

현재와 동일한 수준에서 SiteMapNode 개체(있는 경우)에 상대적인 이전 ParentNode 개체를 가져옵니다.

Provider

SiteMapProvider 개체를 추적하는 SiteMapNode 공급자를 가져옵니다.

ReadOnly

사이트 맵 노드를 수정할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

ResourceKey

SiteMapNode를 지역화하는 데 사용되는 리소스 키를 가져오거나 설정합니다.

Roles

보안 조정 동안 사용되는 SiteMapNode 개체와 연결된 역할의 컬렉션을 가져오거나 설정합니다.

RootNode

사이트 맵 공급자 계층 구조에 있는 루트 공급자의 루트 노드를 가져옵니다. 공급자 계층 구조가 없으면 RootNode 속성에서 현재 공급자의 루트 노드를 가져옵니다.

Title

SiteMapNode 개체의 제목을 가져오거나 설정합니다.

Url

SiteMapNode 개체에서 나타내는 페이지의 URL을 가져오거나 설정합니다.

메서드

Clone()

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

Clone(Boolean)

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

Equals(Object)

현재 SiteMapNode가 지정된 개체와 같은지 여부를 나타내는 값을 가져옵니다.

GetAllNodes()

분리 정도에 상관없이 호출하는 노드의 하위 항목인 모든 SiteMapNode 개체의 읽기 전용 컬렉션을 검색합니다.

GetDataSourceView(SiteMapDataSource, String)

현재 노드와 관련된 SiteMapDataSourceView 개체를 검색합니다.

GetExplicitResourceString(String, String, Boolean)

지역화할 SiteMapNode 특성, 리소스가 없는 경우 반환할 기본 문자열 및 리소스가 없는 경우 예외를 throw할지 여부를 나타내는 부울 값을 기반으로 지역화된 문자열을 검색합니다.

GetHashCode()

SiteMapNode 개체의 해시 코드를 반환합니다.

GetHierarchicalDataSourceView()

현재 노드와 관련된 SiteMapHierarchicalDataSourceView 개체를 검색합니다.

GetImplicitResourceString(String)

ResourceKey를 추적하는 SiteMapProvider에 의해 지정된 SiteMapNode 속성과 특성 이름을 기반으로 지역화된 문자열을 가져옵니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsAccessibleToUser(HttpContext)

사용자가 지정된 컨텍스트에서 지정된 사이트 맵 노드를 볼 수 있는지 여부를 나타내는 값을 가져옵니다.

IsDescendantOf(SiteMapNode)

현재 사이트 맵 노드가 지정된 노드의 자식 또는 직계 하위 노드인지 여부를 나타내는 값을 가져옵니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

SiteMapNode 클래스의 이 인스턴스 값을 해당하는 문자열 표현으로 변환합니다.

명시적 인터페이스 구현

ICloneable.Clone()

현재 노드의 복사본인 새 노드를 만듭니다. 이 멤버에 대한 설명은 Clone()를 참조하세요.

IHierarchyData.GetChildren()

현재 항목의 계층적 자식 데이터 항목을 검색합니다. 이 멤버에 대한 설명은 GetChildren()를 참조하세요.

IHierarchyData.GetParent()

현재 항목의 계층적 부모를 검색합니다. 이 멤버에 대한 설명은 GetParent()를 참조하세요.

IHierarchyData.HasChildren

현재 SiteMapNode 개체에 자식 노드가 있는지를 나타내는 값을 가져옵니다. 이 멤버에 대한 설명은 HasChildren를 참조하세요.

IHierarchyData.Item

계층적 데이터 항목을 가져옵니다. 이 멤버에 대한 설명은 Item를 참조하세요.

IHierarchyData.Path

계층적 데이터 항목의 경로를 가져옵니다. 이 멤버에 대한 설명은 Path를 참조하세요.

IHierarchyData.Type

계층적 데이터 항목의 형식 이름을 나타내는 문자열을 가져옵니다. 이 멤버에 대한 설명은 Type를 참조하세요.

INavigateUIData.Description

사이트 맵 노드의 Description 속성을 가져옵니다. 이 멤버에 대한 설명은 Description를 참조하세요.

INavigateUIData.Name

사이트 맵 노드의 Title 속성을 가져옵니다. 이 멤버에 대한 설명은 Name를 참조하세요.

INavigateUIData.NavigateUrl

사이트 맵 노드의 Url 속성을 가져옵니다. 이 멤버에 대한 설명은 NavigateUrl를 참조하세요.

INavigateUIData.Value

사이트 맵 노드의 Title 속성을 가져옵니다. 이 멤버에 대한 설명은 Value를 참조하세요.

적용 대상

추가 정보