/// <inheritdoc /> public IDependencyConfigurator Add <TService, TImplementation>(InstanceLifetime lifetime) where TService : class where TImplementation : class, TService { this.container.RegisterType <TService, TImplementation>((ITypeLifetimeManager)ParseLifetime(lifetime)); return(this); }
/// <inheritdoc /> public IDependencyConfigurator Add( Type serviceType, Type implementationType, InstanceLifetime lifetime) { this.container.RegisterType( serviceType, implementationType, (ITypeLifetimeManager)ParseLifetime(lifetime)); return(this); }
/// <inheritdoc /> public IDependencyConfigurator Add <TImplementation>( Type serviceType, Func <IDependencyResolver, TImplementation> factory, InstanceLifetime lifetime) { this.container.RegisterFactory( serviceType, c => factory(new UnityDependencyResolver(c)), (IFactoryLifetimeManager)ParseLifetime(lifetime)); return(this); }
private static object ParseLifetime(InstanceLifetime lifetime) => lifetime switch {