IVsDataHostService.GetService<T> 方法 (Guid)

获取移至指定的选件类ID签入实现了指定接口的全局Visual Studio服务。

命名空间:  Microsoft.VisualStudio.Data.Core
程序集:  Microsoft.VisualStudio.Data.Core(在 Microsoft.VisualStudio.Data.Core.dll 中)

语法

声明
Function GetService(Of T) ( _
    serviceGuid As Guid _
) As T
T GetService<T>(
    Guid serviceGuid
)
generic<typename T>
T GetService(
    Guid serviceGuid
)
abstract GetService : 
        serviceGuid:Guid -> 'T 
JScript 不支持泛型类型或方法。

类型参数

  • T
    接口。

参数

  • serviceGuid
    类型:System.Guid
    检索服务的选件类ID。

返回值

类型:T
服务实例。

异常

异常 条件
ServiceNotFoundException

未找到服务。

备注

应为假定始终存在的服务调用此方法。

示例

使用服务ID和接口类型,下面的代码演示调用此方法检索一项标准Visual Studio全局服务。

using System;
using Microsoft.VisualStudio.Data.Core;
using Microsoft.VisualStudio.Shell.Interop;

public class DdexHostSvcExample5
{
    private static readonly Guid SID_IVsUIShell =
        new Guid("B61FC35B-EEBF-4dec-BFF1-28A2DD43C38F");

    public static IVsUIShell GetIVsUIShell(IVsDataHostService hostService)
    {
        return hostService.GetService<IVsUIShell>(SID_IVsUIShell);
    }
}

.NET Framework 安全性

请参见

参考

IVsDataHostService 接口

GetService 重载

Microsoft.VisualStudio.Data.Core 命名空间