IHierarchyData.Item 속성

정의

IHierarchyData 개체가 나타내는 계층적 데이터 노드를 가져옵니다.Gets the hierarchical data node that the IHierarchyData object represents.

public:
 property System::Object ^ Item { System::Object ^ get(); };
public object Item { get; }
member this.Item : obj
Public ReadOnly Property Item As Object

속성 값

Object 계층적 데이터 노드 개체입니다.An Object hierarchical data node object.

예제

다음 코드 예제에 액세스 하는 방법을 보여 줍니다 IHierarchyData 속성의 유형을 확인를 IHierarchyData 를 사용 하 여 개체를 Type 속성과 자세한 형식별 작업을 수행 하려면 개체를 캐스팅 합니다.The following code example demonstrates how to access IHierarchyData properties, check the type of an IHierarchyData object using the Type property, and cast the object to perform more type-specific operations. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 IHierarchyData 인터페이스입니다.This code example is part of a larger example provided for the IHierarchyData interface.

// Print out the current data node, then iterate through its
// children and do the same.
private void PrintFullChildNodeInfo(IHierarchyData node)
{
    string whitespace = "     ";
    string br = "<BR>";

    Response.Write(node.ToString() + br);
    Response.Write(whitespace + node.Path + br);

    // Check for specific types and perform extended functions.
    if (node.Type == "SiteMapNode")
    {
        // Because SiteMapNode implements the IHierarchyData interface,
        // the IHierarchyData object can be cast directly as a SiteMapNode,
        // rather than accessing the Item property for the object that
        // the Type property identifies.
        SiteMapNode siteNode = node.Item as SiteMapNode;
        Response.Write(whitespace + siteNode.Url + br);
        Response.Write(whitespace + siteNode.Description + br);
    }
    else if (node.Type == "SomeBusinessObject")
    {
        // If the IHierarchyData instance is a wrapper class on a business
        // object of some kind, you can retrieve the business object by using
        // the IHierarchyData.Item property.
        //          SomeBusinessObject busObj = node.Item as SomeBusinessObject;
    }

    if (node.HasChildren)
    {
        IEnumerator children = ((IHierarchicalEnumerable)node.GetChildren()).GetEnumerator();

        while (children.MoveNext())
        {
            // Print out SiteMapNode Titles recursively.
            IHierarchyData hierarchicalNode = node.GetChildren().GetHierarchyData(children.Current);
            PrintFullChildNodeInfo(hierarchicalNode);
        }
    }
}
' Print out the current data node, then iterate through its
' children and do the same.

Private Sub PrintFullChildNodeInfo(ByVal node As IHierarchyData)
    Dim whitespace As String = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    Dim br As String = "<BR>"

    Response.Write(Convert.ToString(node) & br)
    Response.Write(whitespace & node.Path & br)

    ' Check for specific types and perform extended functions.
    If node.Type = "SiteMapNode" Then
        ' Because SiteMapNode implements the IHierarchyData interface,
        ' the IHierarchyData object can be cast directly as a SiteMapNode,
        ' rather than accessing the Item property for the object that
        ' the Type property identifies.
        Dim siteNode As SiteMapNode = CType(node.Item, SiteMapNode)
        Response.Write(whitespace & siteNode.Url & br)
        Response.Write(whitespace & siteNode.Description & br)

    ElseIf node.Type = "SomeBusinessObject Then" Then
        ' If the IHierarchyData instance is a wrapper class on a business
        ' object of some kind, you can retrieve the business object by using
        ' the IHierarchyData.Item property.
        '          SomeBusinessObject busObj = node.Item as SomeBusinessObject;
    End If

    If node.HasChildren Then
        Dim children As IEnumerator = CType(node.GetChildren().GetEnumerator(), IHierarchicalEnumerable)
        While children.MoveNext()
            ' Print out SiteMapNode Titles recursively.
            Dim hierarchicalNode As IHierarchyData = node.GetChildren().GetHierarchyData(children.Current)
            PrintFullChildNodeInfo(hierarchicalNode)
        End While
    End If
End Sub

설명

많은 클래스와 같은 계층적 데이터 노드를 나타내는 반면를 SiteMapNode 클래스를 구현 합니다 IHierarchyData 인터페이스를 직접, 다른 클래스는 인터페이스를 구현 하지 않는 클래스에 대 한 래퍼만 작동 합니다.While many classes that represent hierarchical data nodes, such as the SiteMapNode class, implement the IHierarchyData interface directly, other classes only act as a wrapper for a class that does not implement the interface. 합니다 Item 비즈니스 개체는 기능적으로 하는 경우 이러한 디자인 상황에 대 한 속성은 제공는 IHierarchyData 개체 하지만 쉽게 향후 재설계 될 수 없습니다.The Item property is provided for these design situations, when business objects are functionally equivalent to an IHierarchyData object but cannot be redesigned easily.

적용 대상

추가 정보