Information about a specific component
Used to create the build plan
Exemplo n.º 1
0
        /// <summary>
        /// Used to create the correct instance strategy
        /// </summary>
        /// <param name="registration">Registration information</param>
        /// <returns>Strategy to use.</returns>
        protected virtual IInstanceStrategy CreateStrategy(ComponentRegistration registration)
        {
            switch (registration.Lifetime)
            {
            case Lifetime.Transient:
                return(new TransientInstanceStrategy());

            case Lifetime.Scoped:
                return(new ScopedInstanceStrategy(registration.ConcreteType));

            case Lifetime.Singleton:
                return(new SingletonFactoryStrategy());

            default:
                throw new NotSupportedException("Unsupported lifetime: " + registration.Lifetime);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Used to create the correct instance strategy
 /// </summary>
 /// <param name="registration">Registration information</param>
 /// <returns>Strategy to use.</returns>
 protected virtual IInstanceStrategy CreateStrategy(ComponentRegistration registration)
 {
     switch (registration.Lifetime)
     {
         case Lifetime.Transient:
             return new TransientInstanceStrategy();
         case Lifetime.Scoped:
             return new ScopedInstanceStrategy(registration.ConcreteType);
         case Lifetime.Singleton:
             return new SingletonFactoryStrategy();
         default:
             throw new NotSupportedException("Unsupported lifetime: " + registration.Lifetime);
     }
 }