本文整理汇总了C#中System.Web.UI.IHierarchyData.Type属性的典型用法代码示例。如果您正苦于以下问题:C# IHierarchyData.Type属性的具体用法?C# IHierarchyData.Type怎么用?C# IHierarchyData.Type使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Web.UI.IHierarchyData
的用法示例。
在下文中一共展示了IHierarchyData.Type属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintFullChildNodeInfo
// 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);
}
}
}