Skip to content

2.2.0.102

Compare
Choose a tag to compare
@ENikS ENikS released this 12 Nov 01:18

New Features:

New InjectionConstructor(params Type[] types)

Injection constructor could be specified by providing either arguments or types of arguments of the constructor:

Select default constructor:

container.RegisterType<SomeType>(new InjectionConstructor());

Select constructor with SomeType(int, string, float) signature and provide values:

container.RegisterType<SomeType>(new InjectionConstructor(0, string.Empty, 0.0f));

Select constructor with SomeType(string, string, string) signature and provide values for last two:

container.RegisterType<SomeType>(
    new InjectionConstructor(
        new ResolvedParameter(typeof(string)), string.Empty, string.Empty)));

Select constructor with SomeType(string, string, IUnityContainer) signature and provide values for last two:

container.RegisterType<SomeType>( 
    new InjectionConstructor(new Type[] { typeof(string), typeof(string), typeof(IUnityContainer) })));

Note: This change could be breaking and affect selection of a constructor with all parameters of type Type: Constructor(Type type1, Type type2)

Changes to HierarchicalLifetimeManager

Class HierarchicalLifetimeManager now implements IHierarchicalLifetimePolicy interface.
This interface adds method CrateScope() and allows registration of hierarchical lifetime managers with child containers.

RegisterSingleton<>()

Added lineup of extension methods for registering Singletons