Partager via


How to Update Existing Classes

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.]

Updating an existing class is much the same as creating a new one. The main difference is that you get reference to an existing class, perform the desired changes, and mark it for update. Marking the class for update is required so that Service Manager will look for the changes you have made.

Make changes to a management pack class

  1. Get reference to an existing management pack class object.

  2. Alter the class definition in some way like adding a new class property to the PropertyCollection property.

  3. Set the management pack class Status property to PendingUpdate.

  4. Call the AcceptChanges method on the management pack.

Example

The following example demonstrates changing the name and description of a management pack class and then adding a new property:

EnterpriseManagementGroup mg = new EnterpriseManagementGroup("localhost");
ManagementPack mp = new ManagementPack("Folder\\RePackaging.Library.xml", mg);
ManagementPackClass mpClass = mp.GetClass("RePackaging.Request");
ManagementPackProperty mpProp = new ManagementPackProperty(mpClass, "MyNewProperty");

mpClass.Description = "My new description";
mpClass.DisplayName = "My new name";

mpProp.Type = ManagementPackEntityPropertyTypes.@string;
mpClass.PropertyCollection.Add(mpProp);

mpClass.Status = ManagementPackElementStatus.PendingUpdate;
mp.AcceptChanges();

Compiling the Code

Namespaces

Microsoft.EnterpriseManagement

Microsoft.EnterpriseManagement.Configuration

Assemblies

Microsoft.EnterpriseManagement.Core

See Also

Tasks

How to Read a Class From a Management Pack
How to Create a Class
How to Add Properties to a Class

Reference

ManagementPack
ManagementPackClass
ManagementPackElementStatus

Other Resources

Scenario: Managing Classes