HierarchicalDataSourceView.Select メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HierarchicalDataSourceView.Select メソッドの意味・解説 

HierarchicalDataSourceView.Select メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

ビュー内のすべてのデータ項目の一覧を取得します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public MustOverride Function
 Select As IHierarchicalEnumerable
Dim instance As HierarchicalDataSourceView
Dim returnValue As IHierarchicalEnumerable

returnValue = instance.Select
public abstract IHierarchicalEnumerable Select ()
public:
virtual IHierarchicalEnumerable^ Select () abstract
public abstract IHierarchicalEnumerable Select ()
public abstract function Select () : IHierarchicalEnumerable

戻り値
データ項目の IHierarchicalEnumerable コレクション

解説解説
使用例使用例

次のコード例では、HierarchicalDataSourceView クラスから派生したクラスSelect メソッドオーバーライドし、ファイル システムから FileSystemInfo の階層データ取得する方法示しますセキュリティ上の理由で、ファイル システム情報表示されるのは、データ ソース コントロールが、ローカルホスト上で認証された状態で使用されており、そのデータ ソース コントロール使用する Web フォーム ページ存在する仮想ディレクトリでのみ起動する場合限られます。それ以外場合は、ビュー オブジェクトコンストラクタ渡されviewPath パラメータ使用され現在のファイル システム パス基づいてビュー作成されます。このコード例は、HierarchicalDataSourceControl クラストピック取り上げているコード例一部分です。

' The FileSystemDataSourceView class encapsulates the
' capabilities of the FileSystemDataSource data source control.

Public Class FileSystemDataSourceView
   Inherits HierarchicalDataSourceView

   Private _viewPath As String

   Public Sub New(viewPath
 As String)
       ' This implementation of HierarchicalDataSourceView does not
       ' use the viewPath parameter but other implementations
       ' could make use of it for retrieving values.
       _viewPath = viewPath
   End Sub 'New


   ' 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

         ' The ApplicationPath returns a physical path in VB, so do
 not MapPath.
         Dim rootPath As String
 = currentRequest.MapPath(currentRequest.ApplicationPath)

         Dim rootDirectory As New
 DirectoryInfo(rootPath)

         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 'FileSystemDataSourceView
// The FileSystemDataSourceView class encapsulates the
// capabilities of the FileSystemDataSource data source control.
public class FileSystemDataSourceView : HierarchicalDataSourceView
{
private string _viewPath;

    public FileSystemDataSourceView(string
 viewPath)
    {
        // This implementation of HierarchicalDataSourceView does not
        // use the viewPath parameter but other implementations
        // could make use of it for retrieving values.
        _viewPath = 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"))
        {
            string rootPath = currentRequest.MapPath (currentRequest.ApplicationPath);

            DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);

            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.");
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HierarchicalDataSourceView クラス
HierarchicalDataSourceView メンバ
System.Web.UI 名前空間
IEnumerable
IHierarchicalEnumerable



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「HierarchicalDataSourceView.Select メソッド」の関連用語

HierarchicalDataSourceView.Select メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HierarchicalDataSourceView.Select メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS