/// <summary> /// Sets the ownership model of the component. /// </summary> /// <param name="component">The component.</param> /// <param name="registrar">The registrar.</param> protected virtual void SetOwnership <TReflectionActivatorData, TSingleRegistrationStyle>(ComponentElement component, IRegistrationBuilder <object, TReflectionActivatorData, TSingleRegistrationStyle> registrar) where TReflectionActivatorData : ReflectionActivatorData where TSingleRegistrationStyle : SingleRegistrationStyle { //Enforce.ArgumentNotNull(component, "component"); //Enforce.ArgumentNotNull(registrar, "registrar"); if (!string.IsNullOrEmpty(component.Ownership)) { switch (component.Ownership.ToLower()) { case "lifetime-scope": registrar.OwnedByLifetimeScope(); break; case "external": registrar.ExternallyOwned(); break; default: throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, "Unrecognised Ownership:{0}", component.Ownership)); } } }
/// <summary> /// Sets the scope model for the component. /// </summary> /// <param name="component">The component.</param> /// <param name="registrar">The registrar.</param> protected virtual void SetScope <TReflectionActivatorData, TSingleRegistrationStyle>(ComponentElement component, IRegistrationBuilder <object, TReflectionActivatorData, TSingleRegistrationStyle> registrar) where TReflectionActivatorData : ReflectionActivatorData where TSingleRegistrationStyle : SingleRegistrationStyle { //Enforce.ArgumentNotNull(component, "component"); //Enforce.ArgumentNotNull(registrar, "registrar"); if (!string.IsNullOrEmpty(component.InstanceScope)) { switch (component.InstanceScope.ToLower()) { case "single-instance": registrar.SingleInstance(); break; case "per-lifetime-scope": registrar.InstancePerLifetimeScope(); break; case "per-dependency": registrar.InstancePerDependency(); break; default: throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, "Unrecognised Scope:{0}", component.InstanceScope)); } } }
/// <summary> /// Sets the property injection mode for the component. /// </summary> /// <param name="component">The component.</param> /// <param name="registrar">The registrar.</param> protected virtual void SetInjectProperties <TReflectionActivatorData, TSingleRegistrationStyle>(ComponentElement component, IRegistrationBuilder <object, TReflectionActivatorData, TSingleRegistrationStyle> registrar) where TReflectionActivatorData : ReflectionActivatorData where TSingleRegistrationStyle : SingleRegistrationStyle { //Enforce.ArgumentNotNull(component, "component"); //Enforce.ArgumentNotNull(registrar, "registrar"); if (!string.IsNullOrEmpty(component.InjectProperties)) { switch (component.InjectProperties.ToLower()) { case "no": break; case "yes": registrar.PropertiesAutowired((PropertyWiringOptions)1); break; default: throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, "UnrecognisedInject Properties:{0}", component.InjectProperties)); } } }