Edit

Share via


InstrumentationManager Class

Definition

Provides methods that manage the lifetime and the model used for decoupled providers.

Note: the WMI .NET libraries are now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.

public ref class InstrumentationManager abstract sealed
public static class InstrumentationManager
type InstrumentationManager = class
Public Class InstrumentationManager
Inheritance
InstrumentationManager

Examples

The following example demonstrates how to use the publish/revoke model. Two instances of the router class are created and published. They are later revoked.

public class Sample_InstanceProvider
{
    public int Main (string[] args)
    {
        var r_one = new Router();
        r_one.Name = "one";
        InstrumentationManager.Publish(r_one);
        var r_two = new Router ();
        r_two.Name = "two";
        InstrumentationManager.Publish(r_two);
        // ....
        InstrumentationManager.Revoke(r_one);
        InstrumentationManager.Revoke(r_two);
        return 0;
    }
}

In the next example, the callback method of registration is used to expose the RouterNew class.

public int MainNew(string[] args)
{
    InstrumentationManager.RegisterType(typeof(RouterNew));
    // ....
    InstrumentationManager.UnRegisterType(typeof(RouterNew));
    return 0;
}

Remarks

Decoupled providers are hosted by an application. Two methods can be used by the application to make instances of WMI classes available: publish/revoke or the callback method. The callback method uses the RegisterType and UnregisterType methods.

In the publish/revoke model, the WMI infrastructure provides default behavior for many of the methods you have to write yourself in the callback method. These include the enumeration and bind methods. In this model, the application creates instances and publishes them. The application is responsible for ensuring that the key properties of the classes are respected. The application is also responsible for deleting instances.

In the callback model, the WMI infrastructure expects the application to have methods that handle enumeration, binding and any other methods required to implement the functionality of the provider. It calls into the application for this functionality and fails if it does not exist or is not implemented properly. The application registers the type of its WMI classes with the infrastructure by calling RegisterType and indicates that it no longer wants the WMI classes exposed by calling UnregisterType.

Methods

Publish(Object)

Makes an instance of a provider available within the WMI infrastructure.

RegisterAssembly(Assembly)

Registers an assembly with the WMI infrastructure.

RegisterType(Type)

Registers a class with the WMI infrastructure.

Revoke(Object)

Takes an instance of a currently available provider and makes it unavailable within the WMI infrastructure.

UnregisterAssembly(Assembly)

Unregisters an assembly currently registered with the WMI infrastructure.

UnregisterType(Type)

Unregisters a class registered with the WMI infrastructure.

Applies to