本文整理汇总了VB.NET中System.Web.UI.IHierarchyData接口的典型用法代码示例。如果您正苦于以下问题:VB.NET IHierarchyData接口的具体用法?VB.NET IHierarchyData怎么用?VB.NET IHierarchyData使用的例子?那么, 这里精选的接口代码示例或许可以为您提供帮助。
在下文中一共展示了IHierarchyData接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: FileSystemHierarchyData
Public Class FileSystemHierarchyData
Implements IHierarchyData
Public Sub New(ByVal obj As FileSystemInfo)
fileSystemObject = obj
End Sub
Private fileSystemObject As FileSystemInfo = Nothing
Public Overrides Function ToString() As String
Return fileSystemObject.Name
End Function
' IHierarchyData implementation.
Public Overridable ReadOnly Property HasChildren() As Boolean _
Implements IHierarchyData.HasChildren
Get
If GetType(DirectoryInfo) Is fileSystemObject.GetType() Then
Dim temp As DirectoryInfo = _
CType(fileSystemObject, DirectoryInfo)
Return temp.GetFileSystemInfos().Length > 0
Else
Return False
End If
End Get
End Property
' DirectoryInfo returns the OriginalPath, while FileInfo returns
' a fully qualified path.
Public Overridable ReadOnly Property Path() As String _
Implements IHierarchyData.Path
Get
Return fileSystemObject.ToString()
End Get
End Property
Public Overridable ReadOnly Property Item() As Object _
Implements IHierarchyData.Item
Get
Return fileSystemObject
End Get
End Property
Public Overridable ReadOnly Property Type() As String _
Implements IHierarchyData.Type
Get
Return "FileSystemData"
End Get
End Property
Public Overridable Function GetChildren() _
As IHierarchicalEnumerable _
Implements IHierarchyData.GetChildren
Dim children As New FileSystemHierarchicalEnumerable()
If GetType(DirectoryInfo) Is fileSystemObject.GetType() Then
Dim temp As DirectoryInfo = _
CType(fileSystemObject, DirectoryInfo)
Dim fsi As FileSystemInfo
For Each fsi In temp.GetFileSystemInfos()
children.Add(New FileSystemHierarchyData(fsi))
Next fsi
End If
Return children
End Function 'GetChildren
Public Overridable Function GetParent() As IHierarchyData _
Implements IHierarchyData.GetParent
Dim parentContainer As New FileSystemHierarchicalEnumerable()
If GetType(DirectoryInfo) Is fileSystemObject.GetType() Then
Dim temp As DirectoryInfo = _
CType(fileSystemObject, DirectoryInfo)
Return New FileSystemHierarchyData(temp.Parent)
ElseIf GetType(FileInfo) Is fileSystemObject.GetType() Then
Dim temp As FileInfo = CType(fileSystemObject, FileInfo)
Return New FileSystemHierarchyData(temp.Directory)
End If
' If FileSystemObj is any other kind of FileSystemInfo, ignore it.
Return Nothing
End Function 'GetParent
End Class