/// <summary> /// Returns the descriptor for accepting a type based on a condition. /// </summary> /// <param name="accepted">The accepting condition.</param> /// <returns>The descriptor for the type.</returns> public BasedOnDescriptor Where(Predicate <Type> accepted) { var descriptor = new BasedOnDescriptor(typeof(object), this).If(accepted); criterias.Add(descriptor); return(descriptor); }
/// <summary> /// Returns the descriptor for accepting a type. /// </summary> /// <param name = "basedOn"> One or more base types. To be accepted a type must implement at least one of the given base types. </param> /// <returns> The descriptor for the type. </returns> public BasedOnDescriptor BasedOn(IEnumerable <Type> basedOn) { var descriptor = new BasedOnDescriptor(basedOn, this, additionalFilters); Criterias.Add(descriptor); return(descriptor); }
/// <summary> /// Returns the descriptor for accepting a type. /// </summary> /// <param name="basedOn">The base type.</param> /// <returns>The descriptor for the type.</returns> public BasedOnDescriptor BasedOn(Type basedOn) { var descriptor = new BasedOnDescriptor(basedOn, this); criterias.Add(descriptor); return(descriptor); }
/// <summary> /// Initializes a new instance of the ConfigureDescriptor. /// </summary> /// <param name="basedOn">The <see cref="BasedOnDescriptor"/></param> /// <param name="baseType">The base type to match.</param> /// <param name="configurer">The configuration action.</param> public ConfigureDescriptor(BasedOnDescriptor basedOn, Type baseType, Action <ComponentRegistration> configurer) { this.basedOn = basedOn; this.baseType = baseType; this.configurer = configurer; }
/// <summary> /// Returns the descriptor for accepting a type based on a condition. /// </summary> /// <param name = "accepted"> The accepting condition. </param> /// <returns> The descriptor for the type. </returns> public BasedOnDescriptor Where(Predicate <Type> accepted) { var descriptor = new BasedOnDescriptor(new[] { typeof(object) }, this, additionalFilters).If(accepted); Criterias.Add(descriptor); return(descriptor); }
public static DecorationRegistration <BasedOnDescriptor> Decorated(this BasedOnDescriptor extended) { DecoratorApplier decoratorApplier = new DecoratorApplier(); var decorationRegistration = new DecorationRegistration <BasedOnDescriptor>(extended, decoratorApplier); extended.Configure(registration => registration.GetResolveExtensions().Add(decoratorApplier)); return(decorationRegistration); }
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"); }
internal ServiceDescriptor(BasedOnDescriptor basedOnDescriptor) { this.basedOnDescriptor = basedOnDescriptor; }
internal ServiceDescriptor(BasedOnDescriptor basedOnDescriptor) { this.basedOnDescriptor = basedOnDescriptor; }
public static BasedOnDescriptor LifestylePerWebRequest(this BasedOnDescriptor descriptor) { return(descriptor.Configure(c => c.LifestylePerWebRequest())); }
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); } }
/// <summary> /// Initializes a new instance of the ConfigureDescriptor. /// </summary> /// <param name="basedOn">The <see cref="BasedOnDescriptor"/></param> /// <param name="configurer">The configuration action.</param> public ConfigureDescriptor(BasedOnDescriptor basedOn, Action <ComponentRegistration> configurer) : this(basedOn, null, configurer) { }