How to Reference Resources in 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.]
Resources required by management packs are specified with references to external resource files. The external file contains the content of the resource; the management pack only references the resource through a named identifier. The resource files are added to a management pack bundle. Then, when a management pack is installed through that bundle, the bundle provides all the resource data needed. Alternatively, a management pack XML can be imported through code together with a set of file streams that match the resources in the management pack.
Each resource defined in the management pack will have an identifier which is used by the current management pack or by other management packs. The identifier should be unique for the management pack.
There are three types of resources: image, assembly, and report. All of these resource types are created in the same way.
To add an image resource reference to a management pack
Load the management pack to gain reference to the management pack instance.
Create a new instance of the ManagementPackImage class. Specify the management pack instance and a unique identifier for the image reference.
Set the FileName property on the management pack image to the appropriate file name.
Call the AcceptChanges method on the management pack.
Example
The following example demonstrates adding image resource references to a management pack:
EnterpriseManagementGroup mg = new EnterpriseManagementGroup("localhost");
ManagementPack mp = new ManagementPack("Folder\\RePackaging.Library.xml", mg);
ManagementPackImage res1 = new ManagementPackImage(mp, "RePackaging.Library.Resources.Images.Package_16", ManagementPackAccessibility.Public);
ManagementPackImage res2 = new ManagementPackImage(mp, "RePackaging.Library.Resources.Images.Package_32", ManagementPackAccessibility.Public);
ManagementPackImage res3 = new ManagementPackImage(mp, "RePackaging.Library.Resources.Images.Package_64", ManagementPackAccessibility.Public);
res1.FileName = "package_16.png";
res2.FileName = "package_32.png";
res3.FileName = "package_64.png";
mp.AcceptChanges();
<ManagementPack ContentReadable="true" SchemaVersion="1.1" OriginalSchemaVersion="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<Manifest>
<Identity>
<ID>RePackaging.Library</ID>
<Version>1.0.0.0</Version>
</Identity>
<Name>RePackaging Library</Name>
<References>
<Reference Alias="WorkItem">
<ID>System.WorkItem.Library</ID>
<Version>7.0.6555.0</Version>
<PublicKeyToken>9396306c2be7fcc4</PublicKeyToken>
</Reference>
</References>
</Manifest>
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
<ClassType ID="RePackaging.Request" Accessibility="Public" Abstract="false" Base="WorkItem!System.WorkItem" Hosted="false" Singleton="false" Extension="false">
<Property ID="Requester" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" />
<Property ID="SoftwareTitle" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" />
<Property ID="BitsURI" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" />
</ClassType>
</ClassTypes>
</EntityTypes>
</TypeDefinitions>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="false">
<DisplayStrings>
<DisplayString ElementID="RePackaging.Request" SubElementID="Requester">
<Name>Requester</Name>
<Description>The name of the person requesting the software.</Description>
</DisplayString>
<DisplayString ElementID="RePackaging.Request" SubElementID="SoftwareTitle">
<Name>Software Title</Name>
<Description>The title of the software.</Description>
</DisplayString>
<DisplayString ElementID="RePackaging.Request" SubElementID="BitsURI">
<Name>Software Location</Name>
<Description>The URI of the software.</Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
<Resources>
<Image ID="RePackaging.Library.Resources.Images.Package_16" Accessibility="Public" FileName="package_16.png" HasNullStream="false" />
<Image ID="RePackaging.Library.Resources.Images.Package_32" Accessibility="Public" FileName="package_32.png" HasNullStream="false" />
<Image ID="RePackaging.Library.Resources.Images.Package_64" Accessibility="Public" FileName="package_64.png" HasNullStream="false" />
</Resources>
</ManagementPack>
Compiling the Code
Namespaces
Microsoft.EnterpriseManagement |
Microsoft.EnterpriseManagement.Configuration |
Assemblies
Microsoft.EnterpriseManagement.Core |
See Also
Tasks
How to Create a Basic Management Pack
How to Export a Management Pack
Reference
ManagementPackResource
ManagementPackAssemblyResource
ManagementPackImage
ManagementPackReportResource