Share via


Module.GetService(Type) Method

Definition

Retrieves the requested service.

protected:
 virtual System::Object ^ GetService(Type ^ serviceType);
protected virtual object GetService (Type serviceType);
abstract member GetService : Type -> obj
override this.GetService : Type -> obj
Protected Overridable Function GetService (serviceType As Type) As Object

Parameters

serviceType
Type

The Type of the requested IServiceProvider service.

Returns

The requested service object, or null if the service does not exist.

Implements

Examples

The following example shows how to use the GetService method to get a control panel object.


internal class DemoModule : Microsoft.Web.Management.Client.Module 
{

    protected override void Initialize(
        IServiceProvider serviceProvider, ModuleInfo moduleInfo) 
    {

        base.Initialize(serviceProvider, moduleInfo);
        Trace.WriteLine(" ClientModuleTypeName : " + 
            moduleInfo.ClientModuleTypeName);
        Trace.WriteLine(" Name : " + moduleInfo.Name);
        
        // Clear the trace window.
        resetTrace();

        IControlPanel controlPanel = 
            (IControlPanel)GetService(typeof(IControlPanel));
        ModulePageInfo modPgInfo = getModulePage();

        controlPanel.RegisterPage(modPgInfo);
        controlPanel.RegisterPage(
            ControlPanelCategoryInfo.HealthAndDiagnostics, modPgInfo);

Applies to