ActivatorUtilities.CreateFactory Method

Definition

Overloads

CreateFactory(Type, Type[])

Creates a delegate that will instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

CreateFactory<T>(Type[])

Creates a delegate that will instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

CreateFactory(Type, Type[])

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

Creates a delegate that will instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

C#
public static Microsoft.Extensions.DependencyInjection.ObjectFactory CreateFactory(Type instanceType, Type[] argumentTypes);

Parameters

instanceType
Type

The type to activate.

argumentTypes
Type[]

The types of objects, in order, that will be passed to the returned function as its second parameter.

Returns

A factory that will instantiate instanceType using an IServiceProvider and an argument array containing objects matching the types defined in argumentTypes.

Applies to

.NET 10 (package-provided) an aner Versiounen
Produkt Versiounen
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)

CreateFactory<T>(Type[])

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

Creates a delegate that will instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.

C#
public static Microsoft.Extensions.DependencyInjection.ObjectFactory<T> CreateFactory<T>(Type[] argumentTypes);

Type Parameters

T

The type to activate.

Parameters

argumentTypes
Type[]

The types of objects, in order, that will be passed to the returned function as its second parameter.

Returns

A factory that will instantiate type T using an IServiceProvider and an argument array containing objects matching the types defined in argumentTypes.

Applies to

.NET 10 (package-provided) an aner Versiounen
Produkt Versiounen
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)