|
Determine Performance Requirements (Continued)
Pay attention as well to how the stylesheet attempts to cope with WMI’s dual-edged sword: WMI gives you plenty of information, but it can give you too much information. The CIM schema associates numerous metaproperties on its classes, and those are in the XML source document as well. Their NAME attributes start with two underscores, but they add little value to the report you want to see. The sample uses an xsl:choose function here (much as you would use a switch or Select Case statement in other languages), showing off some of XPath’s built-in functions to exclude emitting their XML into the resulting document.
The .NET Framework’s XslTransform (and.NET 2.0’s XslCompiledTransform) allow you to run XSLT stylesheets to transform input XML to the desired output XML. I chose XslTransform for this example because it has overloads returning an XmlReader that allow for straight-through processing of the transformed XML as it gets loaded into the DataSet. In the beta 2 release, XslCompiledTransform offers only overloads returning void, so it doesn’t permit this optimization (I would need to have an intermediate deserialize/serialize step instead), but I’m hopeful this will change in a future release.
The sample includes additional logic that loads the stylesheet and performs the transform (see Listing 3). The ReadXml method call on DataSet accepts an XmlReader, which is precisely what XslTransform returns, so the construction of the DataSet can coincide with the result document that gets formed node by node. After dragging a GridView and auto-formatting it, the last two lines of code databind it to the DataSet. DataSource is set to the DataSet now populated with WMI thread information, and DataBind is called.
Connecting your applications to process and thread objects by databinding to WMI provider information is only the first step. Next, you should explore the other kinds of information WMI provides for building monitoring and management capabilities into your applications. The MSDN Library provides detailed documentation on the properties of classes that you can bind to GridView and FormView controls using the techniques described in this article. When your needs exceed the standard CIM classes, try publishing your own properties and methods. The .NET Framework’s managed support for WMI makes it easy to take advantage of WMI’s features in your applications.
About the Author
Derek Harmon is an R&D engineer at Infragistics and is responsible for the design and development of grid-related ASP.NET presentation-layer elements. Derek is an IBM Certified Solutions Developer in XML & Related Technologies and has more than five years of experience in XML and .NET development.
Back to top
|