IHierarchyData.Type IHierarchyData.Type IHierarchyData.Type IHierarchyData.Type Property

Definition

Ruft den Namen des in der Object-Eigenschaft enthaltenen Typs von Item ab.Gets the name of the type of Object contained in the Item property.

public:
 property System::String ^ Type { System::String ^ get(); };
public string Type { get; }
member this.Type : string
Public ReadOnly Property Type As String

Eigenschaftswert

Der Name des Objekttyps, der vom IHierarchyData-Objekt dargestellt wird.The name of the type of object that the IHierarchyData object represents.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die Grund IHierarchyData Legenden Eigenschaften in HttpResponse einen Stream geschrieben werden. Anschließend wird der IHierarchyData Typ eines Objekts Type mithilfe der-Eigenschaft überprüft und das-Objekt umgewandelt, um weitere typspezifische Vorgänge auszuführen.The following code example demonstrates how to write the basic IHierarchyData properties to an HttpResponse stream, then check the type of an IHierarchyData object using the Type property and cast the object to perform more type-specific operations. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die IHierarchyData -Schnittstelle bereitgestellt wird.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

Hinweise

Die Type -Eigenschaft gibt nicht die System.Type des-Objekts zurück, das IHierarchyData in einem-Objekt dargestellt wird.The Type property does not return the System.Type of the object represented in an IHierarchyData object. Sie gibt einen Namen zurück, der von Daten gebundenen Steuerelementen verwendet wird, um zwischen Elementen in einer Hierarchie zu unterscheiden, die verschiedene bindbare Eigenschaften aufweisen.It returns a name used by data-bound controls to differentiate between items in a hierarchy that have different bindable properties.

Gilt für:

Siehe auch