Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​Extensions.​DependencyInjection.​ActivatorUtilities

Assembly: Microsoft.Extensions.DependencyInjection.Abstractions

Inheritance: object → ActivatorUtilities

Helper code for the various activator services.

Methods

public static ObjectFactory
CreateFactory​(System.​Type instanceType, System.​Type[] argumentTypes)
Creates a delegate that will instantiate a type with constructor arguments provided directly and/or from an <see cref="T:System.IServiceProvider" /> .
Returns A factory that will instantiate instanceType using an <see cref="T:System.IServiceProvider" /> and an argument array containing objects matching the types defined in argumentTypes.
instanceType The type to activate.
argumentTypes The types of objects, in order, that will be passed to the returned function as its second parameter.
public static ObjectFactory<​T>
CreateFactory​(System.​Type[] argumentTypes)
Creates a delegate that will instantiate a type with constructor arguments provided directly and/or from an <see cref="T:System.IServiceProvider" /> .
Returns A factory that will instantiate type <typeparamref name="T" /> using an <see cref="T:System.IServiceProvider" /> and an argument array containing objects matching the types defined in <paramref name="argumentTypes" /> .
argumentTypes The types of objects, in order, that will be passed to the returned function as its second parameter.
public static object
CreateInstance​(System.​IServiceProvider provider, System.​Type instanceType, object[] parameters)
Instantiates a type with constructor arguments provided directly and/or from an <see cref="T:System.IServiceProvider" /> .
Returns An activated object of type instanceType.
provider The service provider used to resolve dependencies.
instanceType The type to activate.
parameters Constructor arguments not provided by the <paramref name="provider" /> .
public static T
CreateInstance​(System.​IServiceProvider provider, object[] parameters)
Instantiates a type with constructor arguments provided directly and/or from an <see cref="T:System.IServiceProvider" /> .
Returns An activated object of type <typeparamref name="T" /> .
provider The service provider used to resolve dependencies.
parameters Constructor arguments not provided by <paramref name="provider" /> .
public static object
GetServiceOrCreateInstance​(System.​IServiceProvider provider, System.​Type type)
Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.
Returns The resolved service or created instance.
provider The service provider.
type The type of the service.
public static T
GetServiceOrCreateInstance​(System.​IServiceProvider provider)
Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.
Returns The resolved service or created instance.
provider The service provider used to resolve dependencies.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object