ActivatorUtilities.CreateFactory 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| CreateFactory(Type, Type[]) |
建立一個代理,能實例化一個型別,並直接提供建構子參數,或直接從 IServiceProvider. |
| CreateFactory<T>(Type[]) |
建立一個代理,能實例化一個型別,並直接提供建構子參數,或直接從 IServiceProvider. |
CreateFactory(Type, Type[])
建立一個代理,能實例化一個型別,並直接提供建構子參數,或直接從 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[]
將傳回函式作為第二個參數的物件類型,依序排列。
傳回
一個工廠,會用一個 IServiceProvider 與參數陣列實例化 instanceType,這些陣列包含與 argumentTypes 定義類型相符的物件。
適用於
CreateFactory<T>(Type[])
建立一個代理,能實例化一個型別,並直接提供建構子參數,或直接從 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定義型別相符的物件。