ServiceProvider.GetGlobalServiceAsync 方法

定义

重载

GetGlobalServiceAsync(Type)

异步获取全局服务。

GetGlobalServiceAsync(Type, Boolean)

异步获取全局服务。

GetGlobalServiceAsync<TService,TInterface>()

异步获取全局服务。

GetGlobalServiceAsync<TService,TInterface>(Boolean)

异步获取全局服务。

GetGlobalServiceAsync(Type)

异步获取全局服务。

public:
 static System::Threading::Tasks::Task<System::Object ^> ^ GetGlobalServiceAsync(Type ^ serviceType);
public static System.Threading.Tasks.Task<object> GetGlobalServiceAsync (Type serviceType);
static member GetGlobalServiceAsync : Type -> System.Threading.Tasks.Task<obj>
Public Shared Function GetGlobalServiceAsync (serviceType As Type) As Task(Of Object)

参数

serviceType
Type

服务的类型标识。

返回

Task<Object>

如果找到,则为其结果为服务的任务;否则 为 null

适用于

GetGlobalServiceAsync(Type, Boolean)

异步获取全局服务。

public:
 static System::Threading::Tasks::Task<System::Object ^> ^ GetGlobalServiceAsync(Type ^ serviceType, bool swallowExceptions);
public static System.Threading.Tasks.Task<object> GetGlobalServiceAsync (Type serviceType, bool swallowExceptions);
static member GetGlobalServiceAsync : Type * bool -> System.Threading.Tasks.Task<obj>
Public Shared Function GetGlobalServiceAsync (serviceType As Type, swallowExceptions As Boolean) As Task(Of Object)

参数

serviceType
Type

服务的类型标识。

swallowExceptions
Boolean

如果此参数为 true,Getserviceasyn 将吞并在 Getserviceasyn 调用期间引发的异常,并返回 null。 如果此项为 false,则在获取服务调用期间引发的异常可能会从方法引发。 如果设置为 false,则不保证所有服务失败或所有服务类型都将引发异常。

返回

Task<Object>

如果找到,则为其结果为服务的任务;否则 为 null

适用于

GetGlobalServiceAsync<TService,TInterface>()

异步获取全局服务。

public:
generic <typename TService, typename TInterface>
 where TService : class where TInterface : class static System::Threading::Tasks::Task<TInterface> ^ GetGlobalServiceAsync();
public static System.Threading.Tasks.Task<TInterface> GetGlobalServiceAsync<TService,TInterface> () where TService : class where TInterface : class;
static member GetGlobalServiceAsync : unit -> System.Threading.Tasks.Task<'Interface (requires 'Interface : null)> (requires 'Service : null and 'Interface : null)
Public Shared Function GetGlobalServiceAsync(Of TService As Class, TInterface As Class) () As Task(Of TInterface)

类型参数

TService

服务的类型标识。

TInterface

要将服务强制转换为的接口。

返回

Task<TInterface>

如果找到,则为其结果为服务的任务;否则 为 null

适用于

GetGlobalServiceAsync<TService,TInterface>(Boolean)

异步获取全局服务。

public:
generic <typename TService, typename TInterface>
 where TService : class where TInterface : class static System::Threading::Tasks::Task<TInterface> ^ GetGlobalServiceAsync(bool swallowExceptions);
public static System.Threading.Tasks.Task<TInterface> GetGlobalServiceAsync<TService,TInterface> (bool swallowExceptions) where TService : class where TInterface : class;
static member GetGlobalServiceAsync : bool -> System.Threading.Tasks.Task<'Interface (requires 'Interface : null)> (requires 'Service : null and 'Interface : null)
Public Shared Function GetGlobalServiceAsync(Of TService As Class, TInterface As Class) (swallowExceptions As Boolean) As Task(Of TInterface)

类型参数

TService

服务的类型标识。

TInterface

要将服务强制转换为的接口。

参数

swallowExceptions
Boolean

如果此参数为 true,Getserviceasyn 将吞并在 Getserviceasyn 调用期间引发的异常,并返回 null。 如果此项为 false,则在获取服务调用期间引发的异常可能会从方法引发。 如果设置为 false,则不保证所有服务失败或所有服务类型都将引发异常。

返回

Task<TInterface>

如果找到,则为其结果为服务的任务;否则 为 null

适用于