示例#1
0
        private LifetimeManager CreateLifetimeManager(DependencyLifetime lifetime, bool isMappedToType)
        {
            if (lifetime.IsTransient)
            {
                return(new TransientLifetimeManager());
            }

            if (lifetime.IsNamed)
            {
                if (isMappedToType)
                {
                    return(new ContainerControlledLifetimeManager());
                }

                return(new ExternallyControlledLifetimeManager());
            }

            if (lifetime.IsScoped)
            {
                return(new HierarchicalLifetimeManager());
            }

            // Not supported lifetime.
            throw Ensure.Exception.NotSupported(lifetime.ToString());
        }