private static BasedOnDescriptor ApplyLifestyle(BasedOnDescriptor registration, Lifestyle lifestyle)
        {
            if (lifestyle.Name == Lifestyle.Singleton.Name)
                return registration.LifestyleSingleton();

            if (lifestyle.Name == Lifestyle.Transient.Name)
                return registration.LifestyleTransient();

            if (lifestyle.Name == Lifestyle.PerWebRequest.Name)
                return registration.LifestylePerWebRequest();

            if (lifestyle.Name == Lifestyle.Unmanaged.Name)
                return registration.LifestyleCustom<UnmanagedLifestyleManager>();

            if (lifestyle.Name == Lifestyle.Default.Name)
                return registration.LifestyleSingleton();

            if (lifestyle.Name == Lifestyle.ProviderDefault.Name)
                return registration;

            throw new ArgumentException(string.Format("Unknown lifestyle : {0}", lifestyle), "lifestyle");
        }
Example #2
0
		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);
			}
		}