コード例 #1
0
        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");
        }
コード例 #2
0
ファイル: CastleIoc.cs プロジェクト: kendarorg/Node.Cs.Old
		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);
			}
		}