HierarchyInfo(IServiceProvider) Constructor
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.
Initializes a new instance of the HierarchyInfo class, using the specified service provider.
protected:
HierarchyInfo(IServiceProvider ^ serviceProvider);
protected HierarchyInfo (IServiceProvider serviceProvider);
new Microsoft.Web.Management.Client.HierarchyInfo : IServiceProvider -> Microsoft.Web.Management.Client.HierarchyInfo
Protected Sub New (serviceProvider As IServiceProvider)
Parameters
- serviceProvider
- IServiceProvider
An IServiceProvider interface.
Examples
The following example creates a new HierarchyInfo instance and adds two items to the Properties property.
internal class DemoHierProvidr : HierarchyProvider
{
private DemoHierarchyInfo _info;
public DemoHierProvidr(IServiceProvider serviceProvider)
: base(serviceProvider)
{
}
public override HierarchyInfo[] GetChildren(HierarchyInfo item)
{
Trace.WriteLine("NodeType = " + item.NodeType +
"\t name = " + this.ToString());
// if we are at the Server level, add our node
if (item.NodeType == HierarchyInfo.ServerConnection)
{
if (_info == null)
{
_info = new DemoHierarchyInfo(this);
}
return new HierarchyInfo[] { _info };
}
return null;
}
public DemoHierarchyInfo(IServiceProvider serviceProvider)
: base(serviceProvider)
{
DemoHierarchyInfoInit();
initTraceP();
}
internal class DemoHierarchyInfo : HierarchyInfo
{
private static string sMachine = "Machine";
private static string sOS = "OSVersion";
static string sPerformance = "Performance";
private static string sDemoCat = sPerformance; // "DemoCategory";
private static string sUDemoH = "UltraDemo";
private System.Collections.IDictionary _dhDict;
private string _sNodeName;
private bool _navSimp = false;
private System.IO.FileStream _objStrm;
HierarchyDemoInfoTaskList _dhTaskList;
public DemoHierarchyInfo(IServiceProvider serviceProvider)
: base(serviceProvider)
{
DemoHierarchyInfoInit();
initTraceP();
}
// return rLoadImg.loadImgs("rTool.bmp");
//System.Drawing.Image.FromFile("rTool.bmp");
public void flush()
{
_objStrm.Flush();
}
void initTraceP()
{
try
{
_objStrm = new System.IO.FileStream(@"C:\AppLog.txt", System.IO.FileMode.OpenOrCreate);
TextWriterTraceListener objTraceListener = new TextWriterTraceListener(_objStrm);
Trace.Listeners.Add(objTraceListener);
Trace.WriteLine("----- " + System.DateTime.Now.ToString());
Trace.Flush();
} catch (System.IO.IOException six)
{
MessageBox.Show("C:\\AppLog.txt cannot be created \n" +
six.Message,
"Tracing disabled");
}
}
protected override void Dispose()
{
Trace.WriteLine("\n ----- Clean Dispose/Flush " + System.DateTime.Now.ToString()
+ "----- \n");
Trace.Flush();
_objStrm.Flush();
return;
//_objStrm.Close();
//base.Dispose();
}
private void DemoHierarchyInfoInit()
{
System.Collections.IDictionary d = Properties;
d.Add(sMachine, System.Environment.MachineName);
d.Add(sOS, System.Environment.OSVersion.ToString());
Trace.WriteLine(" ctor called (DemoHierarchyInfoInit) ");
}
Remarks
This constructor should be called from the derived HierarchyProvider constructor.