ActivatorUtilities.CreateFactory 方法

定义

重载

CreateFactory(Type, Type[])

创建一个委托,该委托将使用直接提供的构造函数参数和/或从 IServiceProvider实例化类型。

CreateFactory<T>(Type[])

创建一个委托,该委托将使用直接提供的或从 IServiceProvider提供的构造函数参数实例化类型。

CreateFactory(Type, Type[])

Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs

创建一个委托,该委托将使用直接提供的构造函数参数和/或从 IServiceProvider实例化类型。

public:
 static Microsoft::Extensions::DependencyInjection::ObjectFactory ^ CreateFactory(Type ^ instanceType, cli::array <Type ^> ^ argumentTypes);
public static Microsoft.Extensions.DependencyInjection.ObjectFactory CreateFactory (Type instanceType, Type[] argumentTypes);
static member CreateFactory : Type * Type[] -> Microsoft.Extensions.DependencyInjection.ObjectFactory
Public Shared Function CreateFactory (instanceType As Type, argumentTypes As Type()) As ObjectFactory

参数

instanceType
Type

要激活的类型。

argumentTypes
Type[]

将作为第二个参数传递给返回的函数的对象类型(按顺序)

返回

 A factory that will instantiate instanceType using an <xref data-throw-if-not-resolved="true" uid="System.IServiceProvider"></xref>
 and an argument array containing objects matching the types defined in argumentTypes

.

适用于

CreateFactory<T>(Type[])

Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs

创建一个委托,该委托将使用直接提供的或从 IServiceProvider提供的构造函数参数实例化类型。

public:
generic <typename T>
 static Microsoft::Extensions::DependencyInjection::ObjectFactory<T> ^ CreateFactory(cli::array <Type ^> ^ argumentTypes);
public static Microsoft.Extensions.DependencyInjection.ObjectFactory<T> CreateFactory<T> (Type[] argumentTypes);
static member CreateFactory : Type[] -> Microsoft.Extensions.DependencyInjection.ObjectFactory<'T>
Public Shared Function CreateFactory(Of T) (argumentTypes As Type()) As ObjectFactory(Of T)

类型参数

T

要激活的类型。

参数

argumentTypes
Type[]

将作为第二个参数传递给返回的函数的对象类型(按顺序)。

返回

一个工厂,它将使用 IServiceProvider 和参数数组实例化类型 T,其中包含与 argumentTypes中定义的类型匹配的对象。

适用于