ServiceProvider.GetService 方法 (Type)

检索具有指定类型的服务。

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

语法

声明
Public Overridable Function GetService ( _
    serviceType As Type _
) As Object
public virtual Object GetService(
    Type serviceType
)
public:
virtual Object^ GetService(
    Type^ serviceType
)
abstract GetService : 
        serviceType:Type -> Object  
override GetService : 
        serviceType:Type -> Object
public function GetService(
    serviceType : Type
) : Object

参数

  • serviceType
    类型:Type

    服务类型。

返回值

类型:Object
如果未找到匹配,返回指定类型的服务或返回 nullnull 引用(在 Visual Basic 中为 Nothing) 服务。

实现

IServiceProvider.GetService(Type)

异常

异常 条件
ArgumentNullException

serviceType 参数为 nullnull 引用(在 Visual Basic 中为 Nothing)。

备注

此方法在以前指定的回调创建服务,返回现有服务或通过父服务获取服务。 如果此方法不得获取服务,它调用父服务提供程序,如果存在)。

.NET Framework 安全性

请参阅

参考

ServiceProvider 类

GetService 重载

Microsoft.VisualStudio.Data.Framework 命名空间