Creating .Net provider with useful CIM metadata? -
07-31-2007
, 04:44 PM
So as far as I can figure, creating a WMI provider in .Net has serious
limitations in that you cannot add metadata to the properties you're exposing.
By this I mean, for example, I might want a WMI property called "Status"
which is a C# enumerated type (for example: Running, Paused, Down, Error).
Is there any way to expose an enumerated type via the .Net WMI stuff? It
seems like whatever's installing the .Net WMI class could pretty easily
reflect into the property and convert it automatically into a CIM "enumerated
type".
What I have had to do is to create a MOF file that maps to my C# WMI
provider class. In that MOF file I am able to add the missing stuff. For my
example above, in the MOF file I have something like:
[Description("The status property contains status information."),
ValueMap{"0","1","2","3"}: ToInstance ToSubClass,
Values("Running","Paused","Down","Error"}: ToInstance ToSubClass] sint32
Status
Then I have to, after running installutil.exe on the executable, run
mofcomp.exe on the MOF file. Yuck!
Is this really the only way to do an enumeration or to add description
metadata to the WMI properties?
Thanks.
- Chris |