HierarchicalDataSourceView 클래스

정의

HierarchicalDataSourceControl 컨트롤에 대한 계층적 데이터 구조의 노드 또는 노드 컬렉션에 데이터 뷰를 나타냅니다.

public ref class HierarchicalDataSourceView abstract
public abstract class HierarchicalDataSourceView
type HierarchicalDataSourceView = class
Public MustInherit Class HierarchicalDataSourceView
상속
HierarchicalDataSourceView
파생

예제

다음 코드 예제에서는 HierarchicalDataSourceView 클래스에서 클래스를 파생시켜 계층적 데이터 스토리지(이 경우 파일 시스템)에서 데이터를 검색하는 방법을 보여줍니다. 합니다 FileSystemDataSourceView 클래스는 강력한 형식의 HierarchicalDataSourceView 와 같은 웹 서버 컨트롤 계층 구조를 사용 하도록 설정 하는 인스턴스는 TreeView 컨트롤을 바인딩할는 FileSystemDataSource 제어 하 고 파일 시스템 정보를 표시 합니다. 보안상의 이유로 파일 시스템 정보의 데이터 소스 컨트롤 localhost에서 사용 중인 경우에 표시 됩니다, 시나리오에서는 인증 및 데이터 소스 컨트롤을 사용 하 여 Web Forms 페이지에 있는 가상 디렉터리에만 시작 됩니다. 그렇지 않은 경우는 viewPath 생성자에 전달 된 매개 변수는 현재 파일 시스템 경로 기준으로 보기를 만드는 데 사용할 수 있습니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 HierarchicalDataSourceControl 클래스입니다.

public class FileSystemDataSourceView : HierarchicalDataSourceView
{
    private string _viewPath;

    public FileSystemDataSourceView(string viewPath)
    {
        HttpRequest currentRequest = HttpContext.Current.Request;
        if (viewPath == "")
        {
            _viewPath = currentRequest.MapPath(currentRequest.ApplicationPath);
        }
        else
        {
            _viewPath = Path.Combine(
                currentRequest.MapPath(currentRequest.ApplicationPath),
                viewPath);
        }
    }

    // Starting with the rootNode, recursively build a list of
    // FileSystemInfo nodes, create FileSystemHierarchyData
    // objects, add them all to the FileSystemHierarchicalEnumerable,
    // and return the list.
    public override IHierarchicalEnumerable Select()
    {
        HttpRequest currentRequest = HttpContext.Current.Request;

        // SECURITY: There are many security issues that can be raised
        // SECURITY: by exposing the file system structure of a Web server
        // SECURITY: to an anonymous user in a limited trust scenario such as
        // SECURITY: a Web page served on an intranet or the Internet.
        // SECURITY: For this reason, the FileSystemDataSource only
        // SECURITY: shows data when the HttpRequest is received
        // SECURITY: from a local Web server. In addition, the data source
        // SECURITY: does not display data to anonymous users.
        if (currentRequest.IsAuthenticated &&
            (currentRequest.UserHostAddress == "127.0.0.1" ||
             currentRequest.UserHostAddress == "::1"))
        {
            DirectoryInfo rootDirectory = new DirectoryInfo(_viewPath);
            if (!rootDirectory.Exists)
            {
                return null;
            }

            FileSystemHierarchicalEnumerable fshe =
                new FileSystemHierarchicalEnumerable();

            foreach (FileSystemInfo fsi
                in rootDirectory.GetFileSystemInfos())
            {
                fshe.Add(new FileSystemHierarchyData(fsi));
            }
            return fshe;
        }
        else
        {
            throw new NotSupportedException(
                "The FileSystemDataSource only " +
                "presents data in an authenticated, localhost context.");
        }
    }
}
Public Class FileSystemDataSourceView
    Inherits HierarchicalDataSourceView

    Private _viewPath As String

    Public Sub New(ByVal viewPath As String)
        Dim currentRequest As HttpRequest = HttpContext.Current.Request
        If viewPath = "" Then
            _viewPath = currentRequest.MapPath(currentRequest.ApplicationPath)
        Else
            _viewPath = Path.Combine(currentRequest.MapPath(currentRequest.ApplicationPath), viewPath)
        End If
    End Sub


    ' Starting with the rootNode, recursively build a list of
    ' FileSystemInfo nodes, create FileSystemHierarchyData
    ' objects, add them all to the FileSystemHierarchicalEnumerable,
    ' and return the list.
    Public Overrides Function [Select]() As IHierarchicalEnumerable
        Dim currentRequest As HttpRequest = HttpContext.Current.Request

        ' SECURITY: There are many security issues that can be raised
        ' SECURITY: by exposing the file system structure of a Web server
        ' SECURITY: to an anonymous user in a limited trust scenario such as
        ' SECURITY: a Web page served on an intranet or the Internet.
        ' SECURITY: For this reason, the FileSystemDataSource only
        ' SECURITY: shows data when the HttpRequest is received
        ' SECURITY: from a local Web server. In addition, the data source
        ' SECURITY: does not display data to anonymous users.
        If currentRequest.IsAuthenticated AndAlso _
            (currentRequest.UserHostAddress = "127.0.0.1" OrElse _
             currentRequest.UserHostAddress = "::1") Then

            Dim rootDirectory As New DirectoryInfo(_viewPath)

            Dim fshe As New FileSystemHierarchicalEnumerable()

            Dim fsi As FileSystemInfo
            For Each fsi In rootDirectory.GetFileSystemInfos()
                fshe.Add(New FileSystemHierarchyData(fsi))
            Next fsi
            Return fshe
        Else
            Throw New NotSupportedException( _
                "The FileSystemDataSource only " + _
                "presents data in an authenticated, localhost context.")
        End If
    End Function 'Select
End Class

설명

ASP.NET 데이터 바인딩 및 일관 된 방식으로 제공 하려면 웹 서버 컨트롤을 사용 하도록 설정 하는 데이터 바인딩 아키텍처를 지원 합니다. 데이터에 바인딩되는 웹 서버 컨트롤에 데이터 바인딩된 컨트롤 이라고 합니다. 및 해당 바인딩을 활용 하는 클래스는 데이터 소스 컨트롤 이라고 합니다. 데이터 소스 컨트롤에서 모든 데이터 소스를 나타낼 수 있습니다: 파일, 스트림, 관계형 데이터베이스, 비즈니스 개체 및 등입니다. 데이터 소스 컨트롤에서 소스 나 기본 데이터의 형식에 관계 없이 데이터 바인딩된 컨트롤에 일관 된 방식으로 데이터를 제공 합니다.

데이터 소스 컨트롤 계층적 데이터를 나타내는 추상에서 파생 HierarchicalDataSourceControl 클래스입니다. 데이터 소스 컨트롤이 데이터 소스 컨트롤 개체와 연결된 된 뷰의 데이터 원본 뷰 개체에 의해 표현 되는 기본 데이터의 조합으로 생각할 수 있습니다. 계층적 데이터 소스 컨트롤에는 이들이 나타내는 데이터의 각 계층 수준에 대 한 계층적 데이터 원본 뷰를 지원 합니다. 데이터 원본 뷰 이름이 지정 되지 않은, 같은 합니다 DataSourceView 와 연결 된 개체는 DataSourceControl 컨트롤 있지만 고유한 계층 경로 의해 식별 됩니다.

데이터 원본 뷰는 데이터 소스 컨트롤의 기능을 정의 합니다. 모든 데이터 원본 뷰 개체를 포함 하 여 HierarchicalDataSourceView를 사용 하 여 기본 데이터 원본에서 데이터 검색을 지원 합니다 Select 데이터의 계층적 목록을 검색 하는 메서드를는 IHierarchicalEnumerable 개체입니다. 모든 데이터 원본 뷰 개체와 같은 작업을 비롯 한 기능의 기본 집합을 필요에 따라 지원 Insert, Update, Delete, 및 정렬 합니다. 데이터 바인딩된 컨트롤을 사용 하 여 연결된 된 데이터 소스를 검색 하 여 데이터 소스 컨트롤의 기능 보기를 검색할 수는 GetHierarchicalView 메서드 및 디자인 타임 또는 런타임 시 뷰를 쿼리 합니다. HierarchicalDataSourceView 현재 지원 하지 않습니다 Insert하십시오 Update 또는 Delete 작업 합니다.

구현자 참고

HierarchicalDataSourceView에서 상속하는 경우 Select() 멤버를 재정의해야 합니다.

생성자

HierarchicalDataSourceView()

HierarchicalDataSourceView 클래스의 새 인스턴스를 초기화합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

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

기본 해시 함수로 작동합니다.

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

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

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

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

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

뷰의 모든 데이터 항목에 대한 목록을 가져옵니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보