Partager via


How to Read a Class From a Management Pack

Applies To: System Center 2012 - Service Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The structure of a management pack class is represented by the ManagementPackClass object. You can reference any class defined in your management pack. Any class defined in another management pack must be public to be referenced. When you want to retrieve object instances of a particular class, you must get reference to that class. A reference to an existing class can be used when you want to extend that class, or when you want to use that class as the base class for a new class.

To get reference to a management pack class

  1. Find the existing System.WorkItem.Library management pack.

  2. Get reference to the System.WorkItem class object.

Example

The following example demonstrates obtaining reference to a management pack class and using it as a base class:

EnterpriseManagementGroup mg = new EnterpriseManagementGroup("localhost");
ManagementPack mp = new ManagementPack("Folder\\RePackaging.Library.xml", mg);
ManagementPack workItemMP = mg.GetManagementPack("System.WorkItem.Library", "9396306c2be7fcc4", new Version(0, 0, 0, 0));
ManagementPackClass workItemClass = workItemMP.GetClass("System.WorkItem");

ManagementPackClass derivedClass = new ManagementPackClass(mp, "MyClass", ManagementPackAccessibility.Public);
derivedClass.Base = workItemClass;

mp.AcceptChanges();

Compiling the Code

Namespaces

Microsoft.EnterpriseManagement

Microsoft.EnterpriseManagement.Configuration

System

Assemblies

Microsoft.EnterpriseManagement.Core

System

See Also

Tasks

How to Create a Class
How to Add Properties to a Class
How to Update Existing Classes

Reference

ClassType
ManagementPackClass

Other Resources

Scenario: Managing Classes