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"); }
/*private static ConfiguredInstance ApplyResolver(GenericFamilyExpression builder, StaticResolver resolver) { return builder.Add(resolver.Target); } private static ObjectInstance ApplyResolver(GenericFamilyExpression builder, InstanceResolver resolver) { return builder.Add(resolver.Instance); } private static LambdaInstance<object> ApplyResolver(GenericFamilyExpression builder, DynamicResolver resolver) { return builder.Add(c => resolver.FactoryFunc()); }*/ private static GenericFamilyExpression ApplyLifestyleSingle(GenericFamilyExpression registration, Lifestyle lifestyle) { if (lifestyle.Name == Lifestyle.Singleton.Name) return registration.Singleton(); if (lifestyle.Name == Lifestyle.Transient.Name) return registration.LifecycleIs(new TransientLifecycle()); if (lifestyle.Name == Lifestyle.PerWebRequest.Name) return registration.LifecycleIs(new UniquePerRequestLifecycle()); if (lifestyle.Name == Lifestyle.Unmanaged.Name) return registration; if (lifestyle.Name == Lifestyle.ProviderDefault.Name) return registration; if (lifestyle.Name == Lifestyle.Default.Name) return registration.Singleton(); throw new ArgumentException(string.Format("Unknown lifestyle : {0}", lifestyle), "lifestyle"); }
private static ComponentRegistration<object> ApplyLifestyle(ComponentRegistration<object> registration, Lifestyle lifestyle) { if (lifestyle.Name == Lifestyle.Singleton.Name) return registration.LifeStyle.Singleton; if (lifestyle.Name == Lifestyle.Transient.Name) return registration.LifeStyle.Transient; if (lifestyle.Name == Lifestyle.PerWebRequest.Name) return registration.LifeStyle.PerWebRequest; if (lifestyle.Name == Lifestyle.Unmanaged.Name) return registration.LifeStyle.Custom<UnmanagedLifestyleManager>(); if (lifestyle.Name == Lifestyle.Default.Name) return registration.LifeStyle.Singleton; if (lifestyle.Name == Lifestyle.ProviderDefault.Name) return registration; throw new ArgumentException(string.Format("Unknown lifestyle : {0}", lifestyle), "lifestyle"); }
protected LifestyleBasedBinding() { Lifestyle = Lifestyle.Default; }