Snippet Guides

New Application Component

Before you begin: Before creating a new class you need to decide on a class ID and a display name. You should also think about if your class should have any properties.

For more information, consult the MP Content document, section Class naming.

Class naming



If the project is not open in Visual Studio, open it.


Add new folder
Right-click the project name in the solution explorer and choose Add\New folder. The name of the folder should be same as the description part of the Class ID. So if the full Class ID is MyCompany.TestMP.3.0.ExportServiceApplicationComponent.Class, the folder would be named ExportServiceApplicationComponent.



Add new item
Right-click the new folder and choose Add\New Item....
In the list, select Empty Management Pack Fragment.



Enter fragment name
Enter a name for the fragment. This should be the same as the folder you created before. Click Add. The fragment is created and opened.


Choose snippet
Right-click between the <ManagementPackFragment> tags and select Insert snippet. Choose MPDevToolkit\Classes\Application Component. Depending on how many properties the class should have, choose the corresponding Computer Role snippet.

Pick one without the dependency monitor. If you want a dependency monitor, there's a seperate snippet/guide for that.
Dependency guide

The code is inserted.





Enter MPID and class name
Enter the MPID and press tab.
Enter the class name. This is the description part of the class ID and should be the same as the folder you created.

Press tab.



If you have choosen a snippet for a class with one or more properties, do the following step for each property. Otherwise, skip this step and continue with Source Class Name.

Enter property name
Enter the name of the property and press tab. Choose a type for the property. If it is a string, just press tab. Otherwise, press Backspace and then press Ctrl-Space. A list of possible types are shown. Pick one and press enter. Press tab. Repeat this for each property.



Enter property name
Enter the description part of the name for the source class for the relationship. This is the class that is hosting the application component. The name entered here is only used to clarify the relationship. It's not used to create the relationship.

For example, if the application component is to be hosted by the Microsoft.Windows.Computer, enter WindowsComputer. Or if you created another class called MyCompany.TestMP.3.0.IntegrationServerComputerRole.Class, enter IntegrationServerComputerRole. Or remove the base class from the description and just enter 'IntegrationServer'. All of these examples makes it fairly easy to understand which class is the source class.

Press tab.



Enter source class ID
Enter the class ID of the source class. This is the full ID of the source class and is used to create the relationship. To use intellisense, press Backspace and then Ctrl+Space.

Press tab.



Enter display name and description
Enter the Class display name you decided on earlier. Press tab. Enter a class description. Press tab.



If you have choosen a snippet for a class with one or more properties, do the following step for each property. Otherwise, skip this and continue to the last step.

Enter property description
The property name is automatically entered as display name. But enter a short description of the property and press tab. Repeat this for each property.



Press enter to stop editing the snippet. The class has now been created.
Save the file/project.

Version: 1.0
Created: 2016-05-23, 11:00