SiteMapNode 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
클래스의 새 인스턴스를 SiteMapNode 초기화하고 지정된 SiteMapProvider 개체와 연결합니다.
오버로드
| Name | Description |
|---|---|
| SiteMapNode(SiteMapProvider, String) |
지정된 |
| SiteMapNode(SiteMapProvider, String, String) |
지정된 URL, |
| SiteMapNode(SiteMapProvider, String, String, String) |
지정된 URL, 노드가 나타내는 페이지, |
| SiteMapNode(SiteMapProvider, String, String, String, String) |
지정된 URL, 노드가 나타내는 페이지, |
| SiteMapNode(SiteMapProvider, String, String, String, String, IList, NameValueCollection, NameValueCollection, String) |
지역화를 위해 노드, URL, 제목, 설명, 역할, 추가 특성 및 명시적 및 암시적 리소스 키를 관리하는 지정된 사이트 맵 공급자를 사용하여 클래스의 새 인스턴스 SiteMapNode 를 초기화합니다. |
SiteMapNode(SiteMapProvider, String)
지정된 key 노드를 사용하여 노드가 나타내는 페이지와 노드를 관리하는 사이트 맵 공급자를 식별하여 클래스의 새 인스턴스 SiteMapNode 를 초기화합니다.
public:
SiteMapNode(System::Web::SiteMapProvider ^ provider, System::String ^ key);
public SiteMapNode(System.Web.SiteMapProvider provider, string key);
new System.Web.SiteMapNode : System.Web.SiteMapProvider * string -> System.Web.SiteMapNode
Public Sub New (provider As SiteMapProvider, key As String)
매개 변수
- provider
- SiteMapProvider
SiteMapProvider 노드가 연결된 항목입니다.
- key
- String
공급자별 조회 키입니다.
예외
설명
ASP.NET 대한 기본 SiteMapProvider 공급자 구현인 클래스는 XmlSiteMapProvider 노드에 대해 제공된 경우 속성을 조회 키로 사용합니다SiteMapNode.Url(URL이 제공되지 않으면 노드에 대한 추적 식별자가 생성됨). 따라서 URL을 제공하고 해당 URL에서 사용되는 XmlSiteMapProvider 모든 SiteMapNode 컨트롤은 공급자 범위 내에 고유한 URL이 있어야 합니다.
적용 대상
SiteMapNode(SiteMapProvider, String, String)
지정된 URL, key 노드가 나타내는 페이지 및 노드를 관리하는 사이트 맵 공급자를 사용하여 클래스의 새 인스턴스 SiteMapNode 를 초기화합니다.
public:
SiteMapNode(System::Web::SiteMapProvider ^ provider, System::String ^ key, System::String ^ url);
public SiteMapNode(System.Web.SiteMapProvider provider, string key, string url);
new System.Web.SiteMapNode : System.Web.SiteMapProvider * string * string -> System.Web.SiteMapNode
Public Sub New (provider As SiteMapProvider, key As String, url As String)
매개 변수
- provider
- SiteMapProvider
SiteMapProvider 노드가 연결된 항목입니다.
- key
- String
공급자별 조회 키입니다.
- url
- String
노드가 사이트 내에서 나타내는 페이지의 URL입니다.
예외
예제
다음 코드 예제에서는 생성자를 사용 하 여 새 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
설명
ASP.NET 대한 기본 SiteMapProvider 공급자 구현인 클래스는 XmlSiteMapProvider 노드에 대해 제공된 경우 속성을 조회 키로 사용합니다SiteMapNode.Url(URL이 제공되지 않으면 노드에 대한 추적 식별자가 생성됨). 따라서 URL을 제공하고 해당 개체에 사용되는 XmlSiteMapProvider 모든 SiteMapNode 개체는 공급자 범위 내에 고유한 URL이 있어야 합니다.
적용 대상
SiteMapNode(SiteMapProvider, String, String, String)
지정된 URL, 노드가 나타내는 페이지, key 제목 및 노드를 관리하는 사이트 맵 공급자를 식별하여 클래스의 새 인스턴스 SiteMapNode 를 초기화합니다.
public:
SiteMapNode(System::Web::SiteMapProvider ^ provider, System::String ^ key, System::String ^ url, System::String ^ title);
public SiteMapNode(System.Web.SiteMapProvider provider, string key, string url, string title);
new System.Web.SiteMapNode : System.Web.SiteMapProvider * string * string * string -> System.Web.SiteMapNode
Public Sub New (provider As SiteMapProvider, key As String, url As String, title As String)
매개 변수
- provider
- SiteMapProvider
SiteMapProvider 노드가 연결된 항목입니다.
- key
- String
공급자별 조회 키입니다.
- url
- String
노드가 사이트 내에서 나타내는 페이지의 URL입니다.
- title
- String
종종 탐색 컨트롤에 의해 표시되는 노드에 대한 레이블입니다.
예외
예제
다음 코드 예제에서는 생성자를 사용하여 SiteMapNode 클래스의 SiteMapNode 새 인스턴스를 만드는 방법을 보여 줍니다. 노드는 Microsoft Access 데이터베이스 행의 값으로 초기화됩니다.
이 코드 예제는 메서드에 제공된 더 큰 예제의 BuildSiteMap 일부입니다.
OleDbCommand^ rootNodeCommand = gcnew OleDbCommand
("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid IS NULL", accessConnection);
OleDbDataReader^ rootNodeReader = rootNodeCommand->ExecuteReader();
if ( rootNodeReader->HasRows )
{
rootNodeReader->Read();
rootNodeId = rootNodeReader->GetInt32( 0 );
// Create a SiteMapNode that references the current StaticSiteMapProvider.
rootNode = gcnew SiteMapNode(this, rootNodeId.ToString(),
rootNodeReader->GetString( 1 ),rootNodeReader->GetString( 2 ));
}
else
return nullptr;
rootNodeReader->Close();
OleDbCommand rootNodeCommand =
new OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid IS NULL",
accessConnection);
OleDbDataReader rootNodeReader = rootNodeCommand.ExecuteReader();
if(rootNodeReader.HasRows) {
rootNodeReader.Read();
rootNodeId = rootNodeReader.GetInt32(0);
// Create a SiteMapNode that references the current StaticSiteMapProvider.
rootNode = new SiteMapNode(this,
rootNodeId.ToString(),
rootNodeReader.GetString(1),
rootNodeReader.GetString(2));
}
else
{
return null;
}
rootNodeReader.Close();
Dim rootNodeCommand As New OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid IS NULL", accessConnection)
Dim rootNodeReader As OleDbDataReader = rootNodeCommand.ExecuteReader()
If rootNodeReader.HasRows Then
rootNodeReader.Read()
rootNodeId = rootNodeReader.GetInt32(0)
' Create a SiteMapNode that references the current StaticSiteMapProvider.
aRootNode = New SiteMapNode(Me, rootNodeId.ToString(), rootNodeReader.GetString(1), rootNodeReader.GetString(2))
Else
Return Nothing
End If
rootNodeReader.Close()
설명
ASP.NET 대한 기본 SiteMapProvider 공급자 구현인 클래스는 XmlSiteMapProvider 노드에 대해 제공된 경우 속성을 조회 키로 사용합니다SiteMapNode.Url(URL이 제공되지 않으면 노드에 대한 추적 식별자가 생성됨). 따라서 URL을 제공하고 해당 개체에 사용되는 XmlSiteMapProvider 모든 SiteMapNode 개체는 공급자 범위 내에 고유한 URL이 있어야 합니다.
제공되지 않은 title 경우 속성에 대한 호출은 Title 필드를 반환합니다 String.Empty .
적용 대상
SiteMapNode(SiteMapProvider, String, String, String, String)
지정된 URL, 노드가 나타내는 페이지, key 제목 및 설명 및 노드를 관리하는 사이트 맵 공급자를 식별하여 클래스의 새 인스턴스 SiteMapNode 를 초기화합니다.
public:
SiteMapNode(System::Web::SiteMapProvider ^ provider, System::String ^ key, System::String ^ url, System::String ^ title, System::String ^ description);
public SiteMapNode(System.Web.SiteMapProvider provider, string key, string url, string title, string description);
new System.Web.SiteMapNode : System.Web.SiteMapProvider * string * string * string * string -> System.Web.SiteMapNode
Public Sub New (provider As SiteMapProvider, key As String, url As String, title As String, description As String)
매개 변수
- provider
- SiteMapProvider
SiteMapProvider 노드가 연결된 항목입니다.
- key
- String
공급자별 조회 키입니다.
- url
- String
노드가 사이트 내에서 나타내는 페이지의 URL입니다.
- title
- String
종종 탐색 컨트롤에 의해 표시되는 노드에 대한 레이블입니다.
- description
- String
노드가 나타내는 페이지에 대한 설명입니다.
예외
예제
다음 코드 예제에서는 간단한 텍스트 파일에서 데이터를 구문 분석하여 메모리에 사이트 맵을 빌드하여 생성자를 사용하여 SiteMapNode 개체를 만드는 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
설명
ASP.NET 대한 기본 SiteMapProvider 공급자 구현인 클래스는 XmlSiteMapProvider 노드에 대해 제공된 경우 속성을 조회 키로 사용합니다SiteMapNode.Url(URL이 제공되지 않으면 노드에 대한 추적 식별자가 생성됨). 따라서 URL을 제공하고 해당 개체에 사용되는 XmlSiteMapProvider 모든 SiteMapNode 개체는 공급자 범위 내에 고유한 URL이 있어야 합니다.
아니요 title 또는 description 제공된 경우 또는 Description 속성에 대한 Title 호출은 String.Empty 필드를 반환합니다.
추가 정보
적용 대상
SiteMapNode(SiteMapProvider, String, String, String, String, IList, NameValueCollection, NameValueCollection, String)
지역화를 위해 노드, URL, 제목, 설명, 역할, 추가 특성 및 명시적 및 암시적 리소스 키를 관리하는 지정된 사이트 맵 공급자를 사용하여 클래스의 새 인스턴스 SiteMapNode 를 초기화합니다.
public:
SiteMapNode(System::Web::SiteMapProvider ^ provider, System::String ^ key, System::String ^ url, System::String ^ title, System::String ^ description, System::Collections::IList ^ roles, System::Collections::Specialized::NameValueCollection ^ attributes, System::Collections::Specialized::NameValueCollection ^ explicitResourceKeys, System::String ^ implicitResourceKey);
public SiteMapNode(System.Web.SiteMapProvider provider, string key, string url, string title, string description, System.Collections.IList roles, System.Collections.Specialized.NameValueCollection attributes, System.Collections.Specialized.NameValueCollection explicitResourceKeys, string implicitResourceKey);
new System.Web.SiteMapNode : System.Web.SiteMapProvider * string * string * string * string * System.Collections.IList * System.Collections.Specialized.NameValueCollection * System.Collections.Specialized.NameValueCollection * string -> System.Web.SiteMapNode
Public Sub New (provider As SiteMapProvider, key As String, url As String, title As String, description As String, roles As IList, attributes As NameValueCollection, explicitResourceKeys As NameValueCollection, implicitResourceKey As String)
매개 변수
- provider
- SiteMapProvider
SiteMapProvider 노드가 연결된 항목입니다.
- key
- String
공급자별 조회 키입니다.
- url
- String
노드가 사이트 내에서 나타내는 페이지의 URL입니다.
- title
- String
종종 탐색 컨트롤에 의해 표시되는 노드에 대한 레이블입니다.
- description
- String
노드가 나타내는 페이지에 대한 설명입니다.
- roles
- IList
IList 에서 나타내는 페이지를 볼 수 있는 역할 중입니다SiteMapNode.
- attributes
- NameValueCollection
NameValueCollection 를 초기화하는 데 사용되는 추가 특성 중입니다SiteMapNode.
- explicitResourceKeys
- NameValueCollection
NameValueCollection 지역화에 사용되는 명시적 리소스 키입니다.
- implicitResourceKey
- String
지역화에 사용되는 암시적 리소스 키입니다.
예외
설명
ASP.NET 대한 기본 SiteMapProvider 공급자 구현인 클래스는 XmlSiteMapProvider 노드에 대해 제공된 경우 속성을 조회 키로 사용합니다SiteMapNode.Url(URL이 제공되지 않으면 노드에 대한 추적 식별자가 생성됨). 따라서 URL을 제공하고 해당 개체에 사용되는 XmlSiteMapProvider 모든 SiteMapNode 개체는 공급자 범위 내에 고유한 URL이 있어야 합니다.
생성된 특성 SiteMapNode 의 컬렉션은 NameValueCollection 속성을 통해 Attributes 사용할 수 있으며, 이를 위해 사용자 지정 클래스를 파생하지 않고도 사이트 맵 노드에 추가 특성을 쉽게 적용하고 기능을 확장할 수 있습니다.
IList 역할 컬렉션을 제공하여 속성이 반환true되면 노드를 볼 수 있는 역할 집합을 SecurityTrimmingEnabled 제공합니다. 자세한 내용은 SecurityTrimmingEnabled를 참조하세요.
공급자는 XmlSiteMapProvider 속성을 조회 키로 사용합니다 SiteMapNode.Url . 따라서 공급자에서 사용하는 XmlSiteMapProvider 모든 SiteMapNode 항목은 공급자 범위 내에 고유한 URL이 있어야 합니다.
아니요 title 또는 description 제공된 경우 또는 Description 속성에 대한 Title 호출은 String.Empty 필드를 반환합니다.
지역화를 위한 리소스를 프로그래밍 방식으로 지정하려면 노드의 implicitResourceKey 지역화된 리소스를 식별하는 데 사용할 고유한 이름으로 값을 설정하거나 노드 속성 또는 지역화 value 할 NameValueCollection 사용자 지정 특성이 있는 name 쌍 컬렉션 name/value 으로 설정하고 explicitResourceKeys 노드 속성 또는 사용자 지정 특성에 대한 지역화 값을 포함합니다. 그런 다음, 적절한 .resx 파일에서 지역화된 값을 설정할 수 있습니다. 개체 및 개체의 SiteMapNode 사용자 지정 속성을 지역화하는 TitleDescription방법에 대한 자세한 내용은 방법: Site-Map 데이터 지역화를 참조하세요. 컬렉션의 구문 요구 사항은 explicitResourceKeys 다음을 참조하세요 NameValueCollection.