ActivatorUtilities.CreateInstance 方法

定義

多載

CreateInstance(IServiceProvider, Type, Object[])

使用直接和/或從 IServiceProvider 提供的函式引數將類型具現化。Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

CreateInstance<T>(IServiceProvider, Object[])

使用直接和/或從 IServiceProvider 提供的函式引數將類型具現化。Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

CreateInstance(IServiceProvider, Type, Object[])

使用直接和/或從 IServiceProvider 提供的函式引數將類型具現化。Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

public:
 static System::Object ^ CreateInstance(IServiceProvider ^ provider, Type ^ instanceType, ... cli::array <System::Object ^> ^ parameters);
public static object CreateInstance (IServiceProvider provider, Type instanceType, params object[] parameters);
static member CreateInstance : IServiceProvider * Type * obj[] -> obj
Public Shared Function CreateInstance (provider As IServiceProvider, instanceType As Type, ParamArray parameters As Object()) As Object

參數

provider
IServiceProvider

用於解析相依性的服務提供者The service provider used to resolve dependencies

instanceType
Type

要啟動的類型The type to activate

parameters
Object[]

provider 未提供的函式引數。Constructor arguments not provided by the provider.

傳回

Object

InstanceType 類型的已啟用物件An activated object of type instanceType

適用於

CreateInstance<T>(IServiceProvider, Object[])

使用直接和/或從 IServiceProvider 提供的函式引數將類型具現化。Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

public:
generic <typename T>
 static T CreateInstance(IServiceProvider ^ provider, ... cli::array <System::Object ^> ^ parameters);
public static T CreateInstance<T> (IServiceProvider provider, params object[] parameters);
static member CreateInstance : IServiceProvider * obj[] -> 'T
Public Shared Function CreateInstance(Of T) (provider As IServiceProvider, ParamArray parameters As Object()) As T

類型參數

T

要啟動的類型The type to activate

參數

provider
IServiceProvider

用於解析相依性的服務提供者The service provider used to resolve dependencies

parameters
Object[]

provider 未提供的函式引數。Constructor arguments not provided by the provider.

傳回

T

T 類型的已啟用物件An activated object of type T

適用於