Base Classes
This page is now retired and kept for archival purposes. This programming guide has been published on MSDN at http://msdn.microsoft.com/library/jj860311.aspx
The information in this topic applies only to System Center 2012 SP1.
The Virtual Machine Manager (VMM) console add-in framework provides two base classes which define the basic functionality of your add-in: ActionAddInBase and ViewAddInBase. Both of these classes inherit from VmmAddInBase.
No matter which class you inherit from, you will need to declare the System.Addin.AddinAttribute attribute for your class. The name provided for that attribute should match the name of an add-in defined in the add-in package manifest.
The VmmAddInBase class
The Microsoft.SystemCenter.VirtualMachineManager.UIAddIns.VmmAddInBase base class is provided by the framework, but not for your own add-ins. This class is the base class of the other add-in base classes that you will derive from. This class does provide common functionality and helper object instances that you will use from your add-in.
This class provides multiple methods for you to override. The following table details those overrides:
Method | Description |
---|---|
OnLoad |
Called when the VMM console loads your add-in. This method is an ideal place to add initialization code. |
OnUnload |
Called when the VMM console unloads your add-in. Any cleanup code can be added here. |
GetButtonLabelString |
This method returns a string for the ribbon button that represents this add-in. If a null string is returned, the text for the ribbon will be loaded from the add-in manifest. This method will allow you to localize the ribbon button label. You can also use this to make the ribbon button label dynamic. |
The ActionAddInBase class
The Microsoft.SystemCenter.VirtualMachineManager.UIAddIns.ActionAddInBase base class defines an add-in that supplies custom code to be executed when invoked by the console. When a user clicks the associated a ribbon button, the PerformAction method is called, which you should override in your derived class. This method receives a list of context objects representing the objects selected in the console at the time of the ribbon button click.
The CheckIfEnabledFor method is defined by the base class and is called anytime items are selected in the console. If this method returns true, the ribbon button will be enabled, and false would disable the button. While you can have your ribbon button appear for all objects of a specific type, this allows you to dictate when a user is allowed to click on the button.
The ViewAddInBase class
The Microsoft.SystemCenter.VirtualMachineManager.UIAddIns.ViewAddInBase base class defines an add-in that supplies a view to the VMM console. This view is a Windows Presentation Foundation FrameworkElement class instance. The view is created when the ribbon button is first clicked and is then cached. Any subsequent click does not recreate the view, but instead shows the cached view. The CreateViewControl method should be overridden, and is responsible for creating and returning the FrameworkElement class instance to be displayed in the console. As stated, this method is only called once, the first time the ribbon button is clicked.
The CurrentScopeType property is a ContextTypes.AddInContextType enumeration value. This property is set when the consoles selected item changes. It represents the type of object being selected in the console.
Depending on the type of object identified by the CurrentScopeType property, the CurrentScopeObject property may be set to a context object representing the VMM object selected in the console. However, it may be null.
You can also override the OnShow and OnHide methods. These methods are called respectively when the view is shown or hidden from view.
See Also
[[Architecture Concepts]]
[[Manifests]]
[[Context Object Types]]