Export (0) Print
Expand All

HierarchyService Class

Contains all the members for customizing the tree view in the Connections pane in IIS Manager. 


Namespace:  Microsoft.Web.Management.Client
Assembly:  Microsoft.Web.Management (in Microsoft.Web.Management.dll)

public abstract class HierarchyService

The HierarchyService type exposes the following members.

Protected methodHierarchyServiceInitializes a new instance of the HierarchyService class.

Public propertySelectedInfoWhen overridden in a derived class, gets the hierarchy information for the selected node.

Public methodAddChildrenWhen overridden in a derived class, adds the specified child nodes to the parent node.
Public methodCollapseWhen overridden in a derived class, collapses the specified node.
Public methodEquals (Inherited from Object.)
Public methodExpandWhen overridden in a derived class, expands the specified node.
Protected methodFinalize (Inherited from Object.)
Public methodGetChildrenWhen overridden in a derived class, returns the collection of child nodes of the specified node.
Public methodGetHashCode (Inherited from Object.)
Public methodGetTasksWhen overridden in a derived class, retrieves a collection of tasks for the node.
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodRefreshWhen overridden in a derived class, refreshes the Connections pane in IIS Manager.
Public methodRemoveWhen overridden in a derived class, removes the specified node from the Connections pane in IIS Manager.
Public methodSelectWhen overridden in a derived class, selects the specified node in the Connections pane in IIS Manager. 
Public methodSyncSelectionWhen overridden in a derived class, synchronizes the node in the Connections pane tree view to a specified node.
Public methodToString (Inherited from Object.)
Public methodUpdateWhen overridden in a derived class, updates the view of the specified node.

Public eventChildrenAddedOccurs when child nodes are added to a node, either through the IIS Manager user interface or programmatically.
Public eventInfoCollapsedOccurs when a node is collapsed, either through the IIS Manager user interface or programmatically.
Public eventInfoExpandedOccurs when a node is expanded, either through the IIS Manager user interface or programmatically.
Public eventInfoRefreshedOccurs when a node is refreshed, either through the IIS Manager user interface or programmatically.
Public eventInfoRemovedOccurs when a node is removed from the hierarchy in the Connections pane, either through the IIS Manager user interface or programmatically. 
Public eventInfoUpdatedOccurs when the hierarchy service is updated.
Public eventSelectedInfoChangedOccurs when the selected object is changed.

You can get a reference to a HierarchyService object through a service provider. You can use the HierarchyService to handle the tree programmatically, exposing methods to perform actions such as expanding or collapsing a node, selecting a node, and refreshing a node.

The hierarchy is displayed in the Connections pane of IIS Manager. This class provides the extensibility features of the hierarchy tree.

The members of this abstract class are empty. This class exists as a convenience for creating HierarchyService objects.

The HierarchyInfo object represents a node in the Connections pane and is a key object in the HierarchyService class.

The following example demonstrates most of the events and methods of the HierarchyService class.

    private HierarchyService _hierarchyService;

    public DemoHierarchyProvider(IServiceProvider serviceProvider)
        : base(serviceProvider) {
        // Register the provider
        _hierarchyService = (HierarchyService)GetService(typeof(HierarchyService));

        // Refer to the customized events
        _hierarchyService.InfoRefreshed += new HierarchyInfoEventHandler(OnHierarchServiceInfoRefreshed);
        _hierarchyService.InfoCollapsed += new HierarchyInfoEventHandler(OnHierarchServiceInfoCollapsed);
        _hierarchyService.InfoExpanded += new HierarchyInfoEventHandler(OnHierarchServiceInfoExpanded);
        _hierarchyService.ChildrenAdded += new HierarchyCollectionEventHandler(OnHierarchServiceChildrenAdded);
        _hierarchyService.InfoRemoved += new HierarchyInfoEventHandler(OnHierarchServiceInfoRemoved);

    // Add these customized events
    // The InfoRefreshed event.
    private void OnHierarchServiceInfoRefreshed(object sender, HierarchyInfoEventArgs e) {
        MessageBox.Show(e.HierarchyInfo.Text + " refreshed");

    // The InfoCollapsed event.
    private void OnHierarchServiceInfoCollapsed(object sender, HierarchyInfoEventArgs e) {
        MessageBox.Show(e.HierarchyInfo.Text + " collapsed");

    // The InfoExpanded event.
    private void OnHierarchServiceInfoExpanded(object sender, HierarchyInfoEventArgs e) {
        string message;
        message = e.HierarchyInfo.Text + " expanded";
        message = message + "\nchild node of " + e.HierarchyInfo.Parent.Text;

    // The ChildrenAdded event.
    private void OnHierarchServiceChildrenAdded(object sender, HierarchyCollectionEventArgs e) {
        MessageBox.Show(e.HierarchyInfo.Text + " has added a child.");

    // The InfoRemoved event.
    private void OnHierarchServiceInfoRemoved(object sender, HierarchyInfoEventArgs e) {
        MessageBox.Show(e.HierarchyInfo.Text + " removed");

    public override HierarchyInfo[] GetChildren(HierarchyInfo item) {
        if (item.NodeType == HierarchyInfo.ServerConnection) {
            return new HierarchyInfo[] { new DemoHierarchyInfo(this) };

        return null;

    internal class DemoHierarchyInfo : HierarchyInfo {

        public DemoHierarchyInfo(IServiceProvider serviceProvider)
            : base(serviceProvider) {

        public override string NodeType {
            get {
                return "DemoHierarchyInfo";

        public override bool SupportsChildren {
            get {
                return false;

        public override string Text {
            get {
                return "Demo Page";

        protected override bool OnSelected() {
            return Navigate(typeof(DemoPage));

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

© 2015 Microsoft