private static BasedOnDescriptor ApplyLifecycle(BasedOnDescriptor registration, Lifecycle lifecycle) { if (lifecycle.Name == Lifecycle.Singleton.Name) return registration.LifestyleSingleton(); if (lifecycle.Name == Lifecycle.Transient.Name) return registration.LifestyleTransient(); if (lifecycle.Name == Lifecycle.PerWebRequest.Name) return registration.LifestylePerWebRequest(); if (lifecycle.Name == Lifecycle.Unmanaged.Name) return registration.LifestyleCustom<UnmanagedLifestyleManager>(); if (lifecycle.Name == Lifecycle.Default.Name) return registration.LifestyleSingleton(); if (lifecycle.Name == Lifecycle.ProviderDefault.Name) return registration; throw new ArgumentException(string.Format("Unknown Lifecycle : {0}", lifecycle), "lifecycle"); }
private BasedOnDescriptor InitializeLifeStyle(IClass component, BasedOnDescriptor componentFor) { switch (component.LifeStyle) { case (LifeStyle.Singleton): return componentFor.LifestyleSingleton(); case (LifeStyle.Transient): return componentFor.LifestyleTransient(); case (LifeStyle.WebRequest): return componentFor.LifestylePerWebRequest(); case (LifeStyle.Pooled): return componentFor.LifestylePooled(); default: throw new ContainerException("LifeStyle not allowed " + component.LifeStyle); } }