/// <summary> /// Registers a type in the container. /// </summary> /// <param name="fromType">The registration type.</param> /// <param name="toType">The type implementing the registration type.</param> /// <param name="scope">Scope of the registered type.</param> /// <returns> /// The <see cref="IContainerAdapter"/> with the newly registered element. /// </returns> public IContainerAdapter RegisterType(Type fromType, Type toType, ContainerRegistrationScope scope) { var builder = new ContainerBuilder(); { if (scope.IsSingleton()) { builder.RegisterType(toType).As(fromType).SingleInstance(); } else { builder.RegisterType(toType).As(fromType).InstancePerDependency(); } } builder.Update(Container); return(this); }
public IContainerAdapter RegisterType <TFrom, TTo>(ContainerRegistrationScope scope) where TTo : TFrom { var builder = new ContainerBuilder(); { if (scope.IsSingleton()) { builder.RegisterType <TTo>().As <TFrom>().SingleInstance(); } else { builder.RegisterType <TTo>().As <TFrom>().InstancePerDependency(); } } builder.Update(Container); return(this); }