Muokkaa

Jaa


IHierarchicalEnumerable Interface

Definition

Represents a hierarchical collection that can be enumerated with an IEnumerator interface. Collections that implement the IHierarchicalEnumerable interface are used by ASP.NET site navigation and data source controls.

public interface class IHierarchicalEnumerable : System::Collections::IEnumerable
public interface IHierarchicalEnumerable : System.Collections.IEnumerable
type IHierarchicalEnumerable = interface
    interface IEnumerable
Public Interface IHierarchicalEnumerable
Implements IEnumerable
Derived
Implements

Examples

The following code example demonstrates how to implement the IHierarchicalEnumerable interface with a class that extends ArrayList and provides a collection of IHierarchyData objects that wrap FileSystemInfo objects. The IHierarchicalEnumerable collection is used by classes that derive from HierarchicalDataSourceView to return a collection of hierarchical nodes when the Select method is called. This code example is part of a larger example provided for the HierarchicalDataSourceControl class.

// A collection of FileSystemHierarchyData objects
public class FileSystemHierarchicalEnumerable :
    ArrayList, IHierarchicalEnumerable
{
    public FileSystemHierarchicalEnumerable()
        : base()
    {
    }

    public IHierarchyData GetHierarchyData(object enumeratedItem)
    {
        return enumeratedItem as IHierarchyData;
    }
}

Public Class FileSystemHierarchicalEnumerable
    Inherits ArrayList
    Implements IHierarchicalEnumerable

    Public Sub New()
    End Sub


    Public Overridable Function GetHierarchyData( _
        ByVal enumeratedItem As Object) As IHierarchyData _
        Implements IHierarchicalEnumerable.GetHierarchyData

        Return CType(enumeratedItem, IHierarchyData)
    End Function

End Class

Remarks

The IHierarchicalEnumerable interface extends the IEnumerable interface and exposes GetHierarchyData, which is a method used to retrieve an IHierarchyData object from an enumerated item, in addition to the GetEnumerator method.

Typically, clients that use IHierarchicalEnumerable collections retrieve an IEnumerator object by calling the GetEnumerator method, then iterate through the enumeration and call the GetHierarchyData on each enumerated item to retrieve an IHierarchyData object.

Methods

GetEnumerator()

Returns an enumerator that iterates through a collection.

(Inherited from IEnumerable)
GetHierarchyData(Object)

Returns a hierarchical data item for the specified enumerated item.

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also