HierarchyService Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains all the members for customizing the tree view in the Connections pane in IIS Manager.
public ref class HierarchyService abstract
public abstract class HierarchyService
type HierarchyService = class
Public MustInherit Class HierarchyService
- Inheritance
-
HierarchyService
Examples
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;
MessageBox.Show(message);
}
// 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));
}
}
}
Remarks
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.
Constructors
HierarchyService() |
Initializes a new instance of the HierarchyService class. |
Properties
SelectedInfo |
When overridden in a derived class, gets the hierarchy information for the selected node. |
Methods
AddChildren(HierarchyInfo, IEnumerable<HierarchyInfo>) |
When overridden in a derived class, adds the specified child nodes to the parent node. |
Collapse(HierarchyInfo) |
When overridden in a derived class, collapses the specified node. |
Expand(HierarchyInfo) |
When overridden in a derived class, expands the specified node. |
GetChildren(HierarchyInfo) |
When overridden in a derived class, returns the collection of child nodes of the specified node. |
GetTasks(HierarchyInfo) |
When overridden in a derived class, retrieves a collection of tasks for the node. |
Refresh(HierarchyInfo) |
When overridden in a derived class, refreshes the Connections pane in IIS Manager. |
Remove(HierarchyInfo) |
When overridden in a derived class, removes the specified node from the Connections pane in IIS Manager. |
Select(HierarchyInfo) |
When overridden in a derived class, selects the specified node in the Connections pane in IIS Manager. |
SyncSelection(HierarchyInfoSyncSelectionEventArgs) |
When overridden in a derived class, synchronizes the node in the Connections pane tree view to a specified node. |
Update(HierarchyInfo) |
When overridden in a derived class, updates the view of the specified node. |
Events
ChildrenAdded |
Occurs when child nodes are added to a node, either through the IIS Manager user interface or programmatically. |
InfoCollapsed |
Occurs when a node is collapsed, either through the IIS Manager user interface or programmatically. |
InfoExpanded |
Occurs when a node is expanded, either through the IIS Manager user interface or programmatically. |
InfoRefreshed |
Occurs when a node is refreshed, either through the IIS Manager user interface or programmatically. |
InfoRemoved |
Occurs when a node is removed from the hierarchy in the Connections pane, either through the IIS Manager user interface or programmatically. |
InfoUpdated |
Occurs when the hierarchy service is updated. |
SelectedInfoChanged |
Occurs when the selected object is changed. |