Class UnityContainerAsyncExtensions
- Namespace
- Unity
- Assembly
- Unity.Abstractions.dll
Extension class that adds a set of convenience overloads to the IUnityContainerAsync interface.
public static class UnityContainerAsyncExtensions
- Inheritance
-
UnityContainerAsyncExtensions
- Inherited Members
Methods
IsRegistered(IUnityContainerAsync, Type)
Check if a particular type has been registered with the container with the default name.
public static bool IsRegistered(this IUnityContainerAsync container, Type typeToCheck)
Parameters
container
IUnityContainerAsyncContainer to inspect.
typeToCheck
TypeType to check registration for.
Returns
- bool
True if this type has been registered, false if not.
IsRegistered<T>(IUnityContainerAsync)
Check if a particular type has been registered with the container with the default name.
public static bool IsRegistered<T>(this IUnityContainerAsync container)
Parameters
container
IUnityContainerAsyncContainer to inspect.
Returns
- bool
True if this type has been registered, false if not.
Type Parameters
T
Type to check registration for.
IsRegistered<T>(IUnityContainerAsync, string)
Check if a particular type/name pair has been registered with the container.
public static bool IsRegistered<T>(this IUnityContainerAsync container, string nameToCheck)
Parameters
container
IUnityContainerAsyncContainer to inspect.
nameToCheck
stringName to check registration for.
Returns
- bool
True if this type/name pair has been registered, false if not.
Type Parameters
T
Type to check registration for.
RegisterFactory(IUnityContainerAsync, Type, Func<IUnityContainerAsync, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static IUnityContainerAsync RegisterFactory(this IUnityContainerAsync container, Type type, Func<IUnityContainerAsync, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
type
TypeType to register (may be an implemented interface instead of the actual type).
factory
Func<IUnityContainerAsync, object>Predefined
to create typesFunc<IUnityContainerAsync, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. This manager has to derive from IFactoryLifetimeManager
Returns
- IUnityContainerAsync
The IUnityContainerAsync object that this method was called on.
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterFactory(IUnityContainerAsync, Type, Func<IUnityContainerAsync, Type, string, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static IUnityContainerAsync RegisterFactory(this IUnityContainerAsync container, Type type, Func<IUnityContainerAsync, Type, string, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
type
TypeType to register (may be an implemented interface instead of the actual type).
factory
Func<IUnityContainerAsync, Type, string, object>Predefined
to create typesFunc<IUnityContainerAsync, Type, string, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. This manager has to derive from IFactoryLifetimeManager
Returns
- IUnityContainerAsync
The IUnityContainerAsync object that this method was called on .
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterFactory(IUnityContainerAsync, Type, string, Func<IUnityContainerAsync, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static IUnityContainerAsync RegisterFactory(this IUnityContainerAsync container, Type type, string name, Func<IUnityContainerAsync, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
type
TypeType to register (may be an implemented interface instead of the actual type).
name
stringName for registration.
factory
Func<IUnityContainerAsync, object>Predefined
to create typesFunc<IUnityContainerAsync, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. This manager has to derive from IFactoryLifetimeManager
Returns
- IUnityContainerAsync
The IUnityContainerAsync object that this method was called on.
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterFactory(IUnityContainerAsync, Type, string, Func<IUnityContainerAsync, Type, string, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static IUnityContainerAsync RegisterFactory(this IUnityContainerAsync container, Type type, string name, Func<IUnityContainerAsync, Type, string, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
type
TypeType to register (may be an implemented interface instead of the actual type).
name
stringName for registration.
factory
Func<IUnityContainerAsync, Type, string, object>Predefined
to create typesFunc<IUnityContainerAsync, Type, string, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. This manager has to derive from IFactoryLifetimeManager
Returns
- IUnityContainerAsync
The IUnityContainerAsync object that this method was called on .
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterFactory<TInterface>(IUnityContainerAsync, Func<IUnityContainer, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static Task RegisterFactory<TInterface>(this IUnityContainerAsync container, Func<IUnityContainer, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
factory
Func<IUnityContainer, object>Predefined
to create typesFunc<IUnityContainer, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. If no manager is provided, container uses Transient manager.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterFactory<TInterface>(IUnityContainerAsync, Func<IUnityContainer, Type, string, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static Task RegisterFactory<TInterface>(this IUnityContainerAsync container, Func<IUnityContainer, Type, string, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
factory
Func<IUnityContainer, Type, string, object>Predefined
to create typesFunc<IUnityContainer, Type, string, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. If no manager is provided, container uses Transient manager.
Returns
- Task
The IUnityContainer object that this method was called on .
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterFactory<TInterface>(IUnityContainerAsync, string, Func<IUnityContainer, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static Task RegisterFactory<TInterface>(this IUnityContainerAsync container, string name, Func<IUnityContainer, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName for registration.
factory
Func<IUnityContainer, object>Predefined
to create typesFunc<IUnityContainer, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. If no manager is provided, container uses Transient manager.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterFactory<TInterface>(IUnityContainerAsync, string, Func<IUnityContainer, Type, string, object>, IFactoryLifetimeManager)
Register a Factory with the container.
public static Task RegisterFactory<TInterface>(this IUnityContainerAsync container, string name, Func<IUnityContainer, Type, string, object> factory, IFactoryLifetimeManager lifetimeManager = null)
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName for registration.
factory
Func<IUnityContainer, Type, string, object>Predefined
to create typesFunc<IUnityContainer, Type, string, object>
lifetimeManager
IFactoryLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance. If no manager is provided, container uses Transient manager.
Returns
- Task
The IUnityContainer object that this method was called on .
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
This overload does a default registration and has the current container take over the lifetime of the factory.
RegisterInstance(IUnityContainerAsync, Type, object)
Register an instance with the container.
public static Task RegisterInstance(this IUnityContainerAsync container, Type t, object instance)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeType of instance to register (may be an implemented interface instead of the full type).
instance
objectObject to returned.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
Remarks
Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.
This overload does a default registration and has the container take over the lifetime of the instance.
RegisterInstance(IUnityContainerAsync, Type, object, IInstanceLifetimeManager)
Register an instance with the container.
public static Task RegisterInstance(this IUnityContainerAsync container, Type t, object instance, IInstanceLifetimeManager lifetimeManager)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeType of instance to register (may be an implemented interface instead of the full type).
instance
objectObject to returned.
lifetimeManager
IInstanceLifetimeManagerLifetimeManager object that controls how this instance will be managed by the container.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
Remarks
Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.
This overload does a default registration (name = null).
RegisterInstance(IUnityContainerAsync, Type, string, object)
Register an instance with the container.
public static Task RegisterInstance(this IUnityContainerAsync container, Type t, string name, object instance)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeType of instance to register (may be an implemented interface instead of the full type).
name
stringName for registration.
instance
objectObject to returned.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
Remarks
Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.
This overload automatically has the container take ownership of the instance
.
RegisterInstance<TInterface>(IUnityContainerAsync, string, TInterface)
Register an instance with the container.
public static Task RegisterInstance<TInterface>(this IUnityContainerAsync container, string name, TInterface instance)
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName for registration.
instance
TInterfaceObject to returned.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.
This overload automatically has the container take ownership of the instance
.
RegisterInstance<TInterface>(IUnityContainerAsync, string, TInterface, IInstanceLifetimeManager)
Register an instance with the container.
public static Task RegisterInstance<TInterface>(this IUnityContainerAsync container, string name, TInterface instance, IInstanceLifetimeManager lifetimeManager)
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName for registration.
instance
TInterfaceObject to returned.
lifetimeManager
IInstanceLifetimeManagerLifetimeManager object that controls how this instance will be managed by the container.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.
RegisterInstance<TInterface>(IUnityContainerAsync, TInterface)
Register an instance with the container.
public static Task RegisterInstance<TInterface>(this IUnityContainerAsync container, TInterface instance)
Parameters
container
IUnityContainerAsyncContainer to configure.
instance
TInterfaceObject to returned.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.
This overload does a default registration and has the container take over the lifetime of the instance.
RegisterInstance<TInterface>(IUnityContainerAsync, TInterface, IInstanceLifetimeManager)
Register an instance with the container.
public static Task RegisterInstance<TInterface>(this IUnityContainerAsync container, TInterface instance, IInstanceLifetimeManager lifetimeManager)
Parameters
container
IUnityContainerAsyncContainer to configure.
instance
TInterfaceObject to returned.
lifetimeManager
IInstanceLifetimeManagerLifetimeManager object that controls how this instance will be managed by the container.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
TInterface
Type of instance to register (may be an implemented interface instead of the full type).
Remarks
Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.
This overload does a default registration (name = null).
RegisterSingleton(IUnityContainerAsync, IEnumerable<Type>, Type, string, params InjectionMember[])
Register a type mapping with the container.
public static Task RegisterSingleton(this IUnityContainerAsync container, IEnumerable<Type> from, Type to, string name, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
from
IEnumerable<Type>Type that will be requested.
to
TypeType that will actually be returned.
name
stringName to use for registration, null if a default registration.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
Remarks
This method is used to tell the container that when asked for type from
,
actually return an instance of type to
. This is very useful for
getting instances of interfaces.
RegisterSingleton(IUnityContainerAsync, IEnumerable<Type>, Type, params InjectionMember[])
Register a type mapping with the container.
public static Task RegisterSingleton(this IUnityContainerAsync container, IEnumerable<Type> from, Type to, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
from
IEnumerable<Type>Type that will be requested.
to
TypeType that will actually be returned.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
Remarks
This method is used to tell the container that when asked for type from
,
actually return an instance of type to
. This is very useful for
getting instances of interfaces.
This overload registers a default mapping.
RegisterSingleton(IUnityContainerAsync, Type, string, params InjectionMember[])
Register a LifetimeManager for the given type and name with the container. No type mapping is performed for this type.
public static Task RegisterSingleton(this IUnityContainerAsync container, Type t, string name, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeThe Type to configure in the container.
name
stringName to use for registration, null if a default registration.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
RegisterSingleton(IUnityContainerAsync, Type, params InjectionMember[])
Register a type with specific members to be injected.
public static Task RegisterSingleton(this IUnityContainerAsync container, Type t, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeType this registration is for.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
RegisterSingleton<T>(IUnityContainerAsync, string, params InjectionMember[])
Register type as a singleton.
public static Task RegisterSingleton<T>(this IUnityContainerAsync container, string name, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName that will be used to request the type.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
T
The type to configure injection on.
RegisterSingleton<T>(IUnityContainerAsync, params InjectionMember[])
Register a type with specific members to be injected as singleton.
public static Task RegisterSingleton<T>(this IUnityContainerAsync container, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
T
Type this registration is for.
RegisterSingleton<TFrom, TTo>(IUnityContainerAsync, string, params InjectionMember[])
Register a type mapping as singleton.
public static Task RegisterSingleton<TFrom, TTo>(this IUnityContainerAsync container, string name, params InjectionMember[] injectionMembers) where TTo : TFrom
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName of this mapping.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
Remarks
This method is used to tell the container that when asked for type TFrom
,
actually return an instance of type TTo
. This is very useful for
getting instances of interfaces.
RegisterSingleton<TFrom, TTo>(IUnityContainerAsync, params InjectionMember[])
Register a type mapping with the container.
public static Task RegisterSingleton<TFrom, TTo>(this IUnityContainerAsync container, params InjectionMember[] injectionMembers) where TTo : TFrom
Parameters
container
IUnityContainerAsyncContainer to configure.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
Remarks
This method is used to tell the container that when asked for type TFrom
,
actually return an instance of type TTo
. This is very useful for
getting instances of interfaces.
This overload registers a default mapping and transient lifetime.
RegisterType(IUnityContainerAsync, IEnumerable<Type>, Type, string, params InjectionMember[])
Register a type mapping with the container.
public static Task RegisterType(this IUnityContainerAsync container, IEnumerable<Type> from, Type to, string name, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
from
IEnumerable<Type>Type that will be requested.
to
TypeType that will actually be returned.
name
stringName to use for registration, null if a default registration.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
Remarks
This method is used to tell the container that when asked for type from
,
actually return an instance of type to
. This is very useful for
getting instances of interfaces.
RegisterType(IUnityContainerAsync, IEnumerable<Type>, Type, params InjectionMember[])
Register a type mapping with the container.
public static Task RegisterType(this IUnityContainerAsync container, IEnumerable<Type> from, Type to, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
from
IEnumerable<Type>Type that will be requested.
to
TypeType that will actually be returned.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
Remarks
This method is used to tell the container that when asked for type from
,
actually return an instance of type to
. This is very useful for
getting instances of interfaces.
This overload registers a default mapping.
RegisterType(IUnityContainerAsync, IEnumerable<Type>, Type, ITypeLifetimeManager, params InjectionMember[])
Register a type mapping with the container, where the created instances will use the given LifetimeManager.
public static Task RegisterType(this IUnityContainerAsync container, IEnumerable<Type> from, Type to, ITypeLifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
from
IEnumerable<Type>Type that will be requested.
to
TypeType that will actually be returned.
lifetimeManager
ITypeLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
RegisterType(IUnityContainerAsync, Type, string, params InjectionMember[])
Register a LifetimeManager for the given type and name with the container. No type mapping is performed for this type.
public static Task RegisterType(this IUnityContainerAsync container, Type t, string name, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeThe Type to configure in the container.
name
stringName to use for registration, null if a default registration.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
RegisterType(IUnityContainerAsync, Type, string, ITypeLifetimeManager, params InjectionMember[])
Register a LifetimeManager for the given type and name with the container. No type mapping is performed for this type.
public static Task RegisterType(this IUnityContainerAsync container, Type t, string name, ITypeLifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeThe Type to apply the
lifetimeManager
to.name
stringName to use for registration, null if a default registration.
lifetimeManager
ITypeLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
RegisterType(IUnityContainerAsync, Type, params InjectionMember[])
Register a type with specific members to be injected.
public static Task RegisterType(this IUnityContainerAsync container, Type t, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeType this registration is for.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
RegisterType(IUnityContainerAsync, Type, ITypeLifetimeManager, params InjectionMember[])
Register a LifetimeManager for the given type and name with the container. No type mapping is performed for this type.
public static Task RegisterType(this IUnityContainerAsync container, Type t, ITypeLifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
t
TypeThe Type to apply the
lifetimeManager
to.lifetimeManager
ITypeLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainerAsync object that this method was called on.
RegisterType<T>(IUnityContainerAsync, string, params InjectionMember[])
Register a LifetimeManager for the given type with the container. No type mapping is performed for this type.
public static Task RegisterType<T>(this IUnityContainerAsync container, string name, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName that will be used to request the type.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
T
The type to configure injection on.
RegisterType<T>(IUnityContainerAsync, string, ITypeLifetimeManager, params InjectionMember[])
Register a LifetimeManager for the given type and name with the container. No type mapping is performed for this type.
public static Task RegisterType<T>(this IUnityContainerAsync container, string name, ITypeLifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName that will be used to request the type.
lifetimeManager
ITypeLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
T
The type to apply the
lifetimeManager
to.
RegisterType<T>(IUnityContainerAsync, params InjectionMember[])
Register a type with specific members to be injected.
public static Task RegisterType<T>(this IUnityContainerAsync container, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
T
Type this registration is for.
RegisterType<T>(IUnityContainerAsync, ITypeLifetimeManager, params InjectionMember[])
Register a LifetimeManager for the given type with the container. No type mapping is performed for this type.
public static Task RegisterType<T>(this IUnityContainerAsync container, ITypeLifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
Parameters
container
IUnityContainerAsyncContainer to configure.
lifetimeManager
ITypeLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
T
The type to apply the
lifetimeManager
to.
RegisterType<TFrom, TTo>(IUnityContainerAsync, string, params InjectionMember[])
Register a type mapping with the container.
public static Task RegisterType<TFrom, TTo>(this IUnityContainerAsync container, string name, params InjectionMember[] injectionMembers) where TTo : TFrom
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName of this mapping.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
Remarks
This method is used to tell the container that when asked for type TFrom
,
actually return an instance of type TTo
. This is very useful for
getting instances of interfaces.
RegisterType<TFrom, TTo>(IUnityContainerAsync, string, ITypeLifetimeManager, params InjectionMember[])
Register a type mapping with the container, where the created instances will use the given LifetimeManager.
public static Task RegisterType<TFrom, TTo>(this IUnityContainerAsync container, string name, ITypeLifetimeManager lifetimeManager, params InjectionMember[] injectionMembers) where TTo : TFrom
Parameters
container
IUnityContainerAsyncContainer to configure.
name
stringName to use for registration, null if a default registration.
lifetimeManager
ITypeLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
RegisterType<TFrom, TTo>(IUnityContainerAsync, params InjectionMember[])
Register a type mapping with the container.
public static Task RegisterType<TFrom, TTo>(this IUnityContainerAsync container, params InjectionMember[] injectionMembers) where TTo : TFrom
Parameters
container
IUnityContainerAsyncContainer to configure.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
Remarks
This method is used to tell the container that when asked for type TFrom
,
actually return an instance of type TTo
. This is very useful for
getting instances of interfaces.
This overload registers a default mapping and transient lifetime.
RegisterType<TFrom, TTo>(IUnityContainerAsync, ITypeLifetimeManager, params InjectionMember[])
Register a type mapping with the container, where the created instances will use the given LifetimeManager.
public static Task RegisterType<TFrom, TTo>(this IUnityContainerAsync container, ITypeLifetimeManager lifetimeManager, params InjectionMember[] injectionMembers) where TTo : TFrom
Parameters
container
IUnityContainerAsyncContainer to configure.
lifetimeManager
ITypeLifetimeManagerThe LifetimeManager that controls the lifetime of the returned instance.
injectionMembers
InjectionMember[]Injection configuration objects.
Returns
- Task
The IUnityContainer object that this method was called on.
Type Parameters
ResolveAsync(IUnityContainerAsync, Type, params ResolverOverride[])
Resolve an instance of the default requested type from the container.
public static ValueTask<object> ResolveAsync(this IUnityContainerAsync container, Type t, params ResolverOverride[] overrides)
Parameters
container
IUnityContainerAsyncContainer to resolve from.
t
TypeType of object to get from the container.
overrides
ResolverOverride[]Any overrides for the resolve call.
Returns
ResolveAsync<T>(IUnityContainerAsync, string, params ResolverOverride[])
Resolve an instance of the requested type with the given name from the container.
public static T ResolveAsync<T>(this IUnityContainerAsync container, string name, params ResolverOverride[] overrides)
Parameters
container
IUnityContainerAsyncContainer to resolve from.
name
stringName of the object to retrieve.
overrides
ResolverOverride[]Any overrides for the resolve call.
Returns
- T
The retrieved object.
Type Parameters
T
Type of object to get from the container.
ResolveAsync<T>(IUnityContainerAsync, params ResolverOverride[])
Resolve an instance of the default requested type from the container.
public static T ResolveAsync<T>(this IUnityContainerAsync container, params ResolverOverride[] overrides)
Parameters
container
IUnityContainerAsyncContainer to resolve from.
overrides
ResolverOverride[]Any overrides for the resolve call.
Returns
- T
The retrieved object.
Type Parameters
T
Type of object to get from the container.