/// <summary>
        /// Creates the synchronization attribute from configuration.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <returns>The corresponding synchronization attribute.</returns>
        private SynchronizeAttribute CreateAttributeFromConfig(IConfiguration config)
        {
            SynchronizeAttribute syncAttrib = null;

            if (config != null)
            {
                var contextRef = config.Attributes[Constants.ContextRefAttribute];

                if (contextRef != null)
                {
                    syncAttrib = new SynchronizeAttribute(contextRef);
                }
                else
                {
                    var contextType = config.Attributes[Constants.ContextTypeAttribute];

                    if (contextType != null)
                    {
                        var type = (Type)converter.PerformConversion(contextType, typeof(Type));
                        syncAttrib = new SynchronizeAttribute(type);
                    }
                }

                var useAmbientContext = config.Attributes[Constants.AmbientContextAttribute];

                if (useAmbientContext != null)
                {
                    syncAttrib = syncAttrib ?? new SynchronizeAttribute();
                    syncAttrib.UseAmbientContext = (bool)converter.PerformConversion(useAmbientContext, typeof(bool));
                }
            }

            return(syncAttrib ?? new SynchronizeAttribute());
        }
Пример #2
0
        private void ReadProxyBehaviorFromConfig(ComponentModel model, ComponentProxyBehaviorAttribute behavior)
        {
            if (model.Configuration == null)
            {
                return;
            }
#if !SILVERLIGHT
            var mbrProxy = model.Configuration.Attributes["marshalByRefProxy"];
            if (mbrProxy != null)
            {
                behavior.UseMarshalByRefProxy = converter.PerformConversion <bool?>(mbrProxy).GetValueOrDefault(false);
            }
#endif
            var interfaces = model.Configuration.Children["additionalInterfaces"];
            if (interfaces == null)
            {
                return;
            }
            var list = new List <Type>(behavior.AdditionalInterfaces);
            foreach (var node in interfaces.Children)
            {
                var interfaceTypeName = node.Attributes["interface"];
                var @interface        = converter.PerformConversion <Type>(interfaceTypeName);
                list.Add(@interface);
            }
            behavior.AdditionalInterfaces = list.ToArray();
        }
        protected Type ExtractCustomType(ComponentModel model)
        {
            var customLifestyleTypeRaw = model.Configuration.Attributes["customLifestyleType"];

            if (customLifestyleTypeRaw != null)
            {
                var lifestyle = converter.PerformConversion <Type>(customLifestyleTypeRaw);
                ValidateLifestyleManager(lifestyle);
                return(lifestyle);
            }
            return(null);
        }
        private void CollectForwardedTypes(IKernelInternal kernel, IConfiguration component, string typeName, string id,
                                           IConversionManager converter, List <Type> services)
        {
            if (kernel == null)
            {
                return;
            }
            var forwardedTypes = component.Children["forwardedTypes"];

            if (forwardedTypes == null)
            {
                return;
            }

            foreach (var forwardedType in forwardedTypes.Children
                     .Where(c => c.Name.Trim().Equals("add", StringComparison.InvariantCultureIgnoreCase)))
            {
                var forwardedServiceTypeName = forwardedType.Attributes["service"];
                try
                {
                    services.Add(converter.PerformConversion <Type>(forwardedServiceTypeName));
                }
                catch (Exception e)
                {
                    throw new ComponentRegistrationException(
                              string.Format("Component {0}-{1} defines invalid forwarded type.", id ?? string.Empty, typeName), e);
                }
            }
        }
        private PropertiesInspectionBehavior GetInspectionBehaviorFromTheConfiguration(IConfiguration config)
        {
            if (config == null || config.Attributes["inspectionBehavior"] == null)
            {
                // return default behavior
                return(PropertiesInspectionBehavior.All);
            }

            var enumStringVal = config.Attributes["inspectionBehavior"];

            try
            {
                return(converter.PerformConversion <PropertiesInspectionBehavior>(enumStringVal));
            }
            catch (Exception)
            {
                var message =
                    String.Format(
                        "Error on properties inspection. Could not convert the inspectionBehavior attribute value into an expected enum value. " +
                        "Value found is '{0}' while possible values are '{1}'",
                        enumStringVal,
                        String.Join(", ", Enum.GetNames(typeof(PropertiesInspectionBehavior))));

                throw new ConverterException(message);
            }
        }
Пример #6
0
 private Type GetType(IConversionManager converter, string typeName)
 {
     if (typeName == null)
     {
         return(null);
     }
     return(converter.PerformConversion <Type>(typeName));
 }
Пример #7
0
        private static void DeserializeFacility(XmlNode node, IConfigurationStore store, IConversionManager converter)
        {
            var config   = XmlConfigurationDeserializer.GetDeserializedNode(node);
            var typeName = GetRequiredAttributeValue(config, "type");
            var type     = converter.PerformConversion <Type>(typeName);

            AddFacilityConfig(type.FullName, config, store);
        }
        /// <summary>
        ///   Get the property with given name and type
        /// </summary>
        /// <param name="propertyName">Property name</param>
        /// <param name="targetType">Expected type of the property value</param>
        /// <returns>Property value</returns>
        public virtual object GetValue(string propertyName, Type targetType)
        {
            IConfiguration config = GetConfig(propertyName);

            object propertyValue = m_converter.PerformConversion(config, targetType);

            return(propertyValue);
        }
        /// <summary>
        ///   Finds the parameter by looking at the cache, then in the model configuration.
        /// </summary>
        /// <param name="model">Model of the component that is requesting the dependency</param>
        /// <param name="dependency">The dependcy to satisfy</param>
        /// <returns>True if processing success, else false</returns>
        private bool ProcessDependency(ComponentModel model, DependencyModel dependency)
        {
            string uniqueKey = model.Implementation.FullName + "+" + dependency.DependencyKey;

            if (VALUES.ContainsKey(uniqueKey))
            {
                return(true);
            }

            IConfiguration parameterNodeConfig = model.Configuration.Children[Constants.ParamsConfigKey];

            if (parameterNodeConfig == null)
            {
                return(false);
            }

            IConfiguration paramConfig = parameterNodeConfig.Children.SingleOrDefault(f => f.Name == dependency.DependencyKey);

            if (paramConfig == null)
            {
                return(false);
            }

            //throw new ConfigurationProcessingException(string.Format("Missing parameter value for parameter '{0}'", dependency.DependencyKey));

            EPathType?pathType = RelativePathUtil.GetPathType(paramConfig);

            if (!pathType.HasValue)
            {
                return(false);
            }

            RelativePathUtil.ConvertPaths(paramConfig, null);

            IConfiguration processedConfig = null;

            if (paramConfig.Children.Count > 0)
            {
                IConfiguration firstChild = paramConfig.Children[0];
                string         configName = firstChild.Name.ToLowerInvariant();
                if (SpecialNodes.Contains(configName))
                {
                    processedConfig = new MutableConfiguration(paramConfig.Name, string.Empty);
                    processedConfig.Children.AddRange(firstChild.Children);
                }
            }
            else
            {
                processedConfig = paramConfig;
            }

            object value = m_converter.PerformConversion(processedConfig, dependency.TargetType);

            VALUES[uniqueKey] = value;

            return(true);
        }
        protected virtual void SetUpComponents(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
        {
            foreach (var component in configurations)
            {
                var id              = component.Attributes["id"];
                var typeName        = component.Attributes["type"];
                var serviceTypeName = component.Attributes["service"];

                if (string.IsNullOrEmpty(typeName))
                {
                    continue;
                }

                var type    = converter.PerformConversion <Type>(typeName);
                var service = type;

                if (!string.IsNullOrEmpty(serviceTypeName))
                {
                    service = converter.PerformConversion <Type>(serviceTypeName);
                }

                AssertImplementsService(id, service, type);

                Debug.Assert(id != null);
                Debug.Assert(type != null);
                Debug.Assert(service != null);

                var services = new List <Type> {
                    service
                };
                CollectForwardedTypes(container.Kernel as IKernelInternal, component, typeName, id, converter, services);
                var registration = Component.For(services).ImplementedBy(type);
                if (component.Attributes["id-automatic"] == true.ToString())
                {
                    container.Register(registration.NamedAutomatically(id));
                }
                else
                {
                    container.Register(registration.Named(id));
                }
            }
        }
Пример #11
0
        protected virtual void SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
        {
            foreach (var facility in configurations)
            {
                var type             = converter.PerformConversion <Type>(facility.Attributes["type"]);
                var facilityInstance = type.CreateInstance <IFacility>();
                Debug.Assert(facilityInstance != null);

                container.AddFacility(facilityInstance);
            }
        }
Пример #12
0
        private static void DeserializeComponent(XmlNode node, IConfigurationStore store, IConversionManager converter)
        {
            var config = XmlConfigurationDeserializer.GetDeserializedNode(node);
            var id     = config.Attributes["id"];

            if (string.IsNullOrEmpty(id))
            {
                var type = converter.PerformConversion <Type>(config.Attributes["type"]);
                id = type.FullName;
                config.Attributes["id"] = id;
                config.Attributes.Add("id-automatic", true.ToString());
            }
            AddComponentConfig(id, config, store);
        }
Пример #13
0
        private void AddInstaller(IConfiguration installer, Dictionary <Type, IWindsorInstaller> cache,
                                  IConversionManager conversionManager, ICollection <Assembly> assemblies)
        {
            var typeName = installer.Attributes["type"];

            if (string.IsNullOrEmpty(typeName) == false)
            {
                var type = conversionManager.PerformConversion <Type>(typeName);
                AddInstaller(cache, type);
                return;
            }

            assemblyName = installer.Attributes["assembly"];
            if (string.IsNullOrEmpty(assemblyName) == false)
            {
                var assembly = ReflectionUtil.GetAssemblyNamed(assemblyName);
                if (assemblies.Contains(assembly))
                {
                    return;
                }
                assemblies.Add(assembly);

                GetAssemblyInstallers(cache, assembly);
                return;
            }

            var directory = installer.Attributes["directory"];
            var mask      = installer.Attributes["fileMask"];
            var token     = installer.Attributes["publicKeyToken"];

            Debug.Assert(directory != null, "directory != null");
            var assemblyFilter = new AssemblyFilter(directory, mask);

            if (token != null)
            {
                assemblyFilter.WithKeyToken(token);
            }

            foreach (var assembly in ReflectionUtil.GetAssemblies(assemblyFilter))
            {
                if (assemblies.Contains(assembly))
                {
                    continue;
                }
                assemblies.Add(assembly);
                GetAssemblyInstallers(cache, assembly);
            }
        }
Пример #14
0
		private void AddInstaller(IConfiguration installer, Dictionary<Type, IWindsorInstaller> cache,
		                          IConversionManager conversionManager, ICollection<Assembly> assemblies)
		{
			var typeName = installer.Attributes["type"];
			if (string.IsNullOrEmpty(typeName) == false)
			{
				var type = conversionManager.PerformConversion<Type>(typeName);
				AddInstaller(cache, type);
				return;
			}

			assemblyName = installer.Attributes["assembly"];
			if (string.IsNullOrEmpty(assemblyName) == false)
			{
				var assembly = ReflectionUtil.GetAssemblyNamed(assemblyName);
				if (assemblies.Contains(assembly))
				{
					return;
				}
				assemblies.Add(assembly);

				GetAssemblyInstallers(cache, assembly);
				return;
			}

#if !SILVERLIGHT
			var directory = installer.Attributes["directory"];
			var mask = installer.Attributes["fileMask"];
			var token = installer.Attributes["publicKeyToken"];
			Debug.Assert(directory != null, "directory != null");
			var assemblyFilter = new AssemblyFilter(directory, mask);
			if (token != null)
			{
				assemblyFilter.WithKeyToken(token);
			}

			foreach (var assembly in ReflectionUtil.GetAssemblies(assemblyFilter))
			{
				if (assemblies.Contains(assembly))
				{
					continue;
				}
				assemblies.Add(assembly);
				GetAssemblyInstallers(cache, assembly);
			}
#endif
		}
		private void AddInstaller(IConfiguration installer, Dictionary<Type, IWindsorInstaller> cache, IConversionManager conversionManager)
		{
			var typeName = installer.Attributes["type"];
			if (string.IsNullOrEmpty(typeName) == false)
			{
				var type = conversionManager.PerformConversion(typeName, typeof(Type)) as Type;
				AddInstaller(cache, type);
				return;
			}

			Debug.Assert(string.IsNullOrEmpty(installer.Attributes["assembly"]) == false);
			var types = Assembly.Load(installer.Attributes["assembly"]).GetExportedTypes();
			foreach (var type in InstallerTypes(types))
			{
				AddInstaller(cache, type);
			}
		}
        /// <summary>
        ///   Reads the attribute "componentActivatorType" associated with the
        ///   component configuration and verifies it implements the <see cref = "IComponentActivator" />
        ///   interface.
        /// </summary>
        /// <exception cref = "System.Exception">
        ///   If the type does not implement the proper interface
        /// </exception>
        /// <param name = "model"></param>
        /// <returns></returns>
        protected virtual bool ReadComponentActivatorFromConfiguration(ComponentModel model)
        {
            if (model.Configuration != null)
            {
                var componentActivatorType = model.Configuration.Attributes["componentActivatorType"];
                if (componentActivatorType == null)
                {
                    return(false);
                }

                var customComponentActivator = converter.PerformConversion <Type>(componentActivatorType);
                ValidateComponentActivator(customComponentActivator);

                model.CustomComponentActivator = customComponentActivator;
                return(true);
            }

            return(false);
        }
Пример #17
0
        private bool IsCacheModelOn(IKernel kernel, ComponentModel model)
        {
            IConversionManager converter = kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey) as IConversionManager;
            bool allowCache = false;

            if (model.Configuration != null)
            {
                String enableInterceptionAttribute = model.Configuration.Attributes["Cache"];

                if (enableInterceptionAttribute != null)
                {
                    allowCache = (bool)converter.PerformConversion(enableInterceptionAttribute, typeof(bool));
                }
            }

            if (model.Implementation.IsDefined(typeof(CacheAttribute), true))
            {
                allowCache = true;
            }

            return(allowCache);
        }
        public PropertiesInspectionBehavior GetInspectionBehaviorFromTheConfiguration(IConfiguration config)
        {
            if (config?.Attributes["inspectionBehavior"] == null)
            {
                // return default behavior
                return(PropertiesInspectionBehavior.All);
            }

            var enumStringVal = config.Attributes["inspectionBehavior"];

            try
            {
                return(converter.PerformConversion <PropertiesInspectionBehavior>(enumStringVal));
            }
            catch (Exception)
            {
                var message =
                    string.Format(
                        "Error on properties inspection. Could not convert the inspectionBehavior attribute value into an expected enum value. " +
                        "Value found is '{0}' while possible values are '{1}'",
                        enumStringVal,
                        string.Join(", ",
#if SILVERLIGHT
                                    new[]
                {
                    "Undefined",
                    "None",
                    "All",
                    "DeclaredOnly"
                }
#else
                                    Enum.GetNames(typeof(PropertiesInspectionBehavior))
#endif
                                    ));

                throw new ConverterException(message);
            }
        }
        private static IReference <IProxyGenerationHook> ObtainProxyHook(IConfiguration config, IConversionManager converter)
        {
            IProxyGenerationHook hook = null;

            if (config != null)
            {
                var hookAttrib = config.Attributes[Constants.ControlProxyHookAttrib];

                if (hookAttrib != null)
                {
                    var hookComponent = ReferenceExpressionUtil.ExtractComponentName(hookAttrib);
                    if (hookComponent != null)
                    {
                        return(new ComponentReference <IProxyGenerationHook>(hookComponent));
                    }

                    var hookType = converter.PerformConversion <Type>(hookAttrib);

                    if (hookType.Is <IProxyGenerationHook>() == false)
                    {
                        var message = String.Format("The specified controlProxyHook does " +
                                                    "not implement the interface {1}. Type {0}",
                                                    hookType.FullName, typeof(IProxyGenerationHook).FullName);

                        throw new ConfigurationErrorsException(message);
                    }

                    hook = hookType.CreateInstance <IProxyGenerationHook>();
                }
            }

            if (hook == null)
            {
                hook = SynchronizeProxyHook.Instance;
            }

            return(new InstanceReference <IProxyGenerationHook>(hook));
        }
Пример #20
0
        private void CollectAdditionalServices(IConfiguration component, IConversionManager converter, ICollection <Type> services)
        {
            var forwardedTypes = component.Children["forwardedTypes"];

            if (forwardedTypes == null)
            {
                return;
            }

            foreach (var forwardedType in forwardedTypes.Children)
            {
                var forwardedServiceTypeName = forwardedType.Attributes["service"];
                try
                {
                    services.Add(converter.PerformConversion <Type>(forwardedServiceTypeName));
                }
                catch (ConverterException e)
                {
                    throw new ComponentRegistrationException(
                              string.Format("Component {0} defines invalid forwarded type.", component.Attributes["id"]), e);
                }
            }
        }
		protected virtual void SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container,
		                                       IConversionManager converter)
		{
			foreach (IConfiguration facility in configurations)
			{
				var id = facility.Attributes["id"];
				var typeName = facility.Attributes["type"];
				if (string.IsNullOrEmpty(typeName))
				{
					continue;
				}

				var type = converter.PerformConversion<Type>(typeName);

				var facilityInstance = ReflectionUtil.CreateInstance<IFacility>(type);

				Debug.Assert(id != null);
				Debug.Assert(facilityInstance != null);

				container.AddFacility(id, facilityInstance);
			}
		}
		private void CollectForwardedTypes(IKernelInternal kernel, IConfiguration component, string typeName, string id,
		                                   IConversionManager converter, List<Type> services)
		{
			if (kernel == null)
			{
				return;
			}
			var forwardedTypes = component.Children["forwardedTypes"];
			if (forwardedTypes == null)
			{
				return;
			}

			foreach (var forwardedType in forwardedTypes.Children
				.Where(c => c.Name.Trim().Equals("add", StringComparison.InvariantCultureIgnoreCase)))
			{
				var forwardedServiceTypeName = forwardedType.Attributes["service"];
				try
				{
					services.Add(converter.PerformConversion<Type>(forwardedServiceTypeName));
				}
				catch (Exception e)
				{
					throw new Exception(
						string.Format("Component {0}-{1} defines invalid forwarded type.", id ?? string.Empty, typeName), e);
				}
			}
		}
		protected virtual void SetUpComponents(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
		{
			foreach (var component in configurations)
			{
				var id = component.Attributes["id"];
				var typeName = component.Attributes["type"];
				var serviceTypeName = component.Attributes["service"];

				if (string.IsNullOrEmpty(typeName))
				{
					continue;
				}

				var type = converter.PerformConversion<Type>(typeName);
				var service = type;

				if (!string.IsNullOrEmpty(serviceTypeName))
				{
					service = converter.PerformConversion<Type>(serviceTypeName);
				}

				AssertImplementsService(id, service, type);

				Debug.Assert(id != null);
				Debug.Assert(type != null);
				Debug.Assert(service != null);

				var services = new List<Type> { service };
				CollectForwardedTypes(container.Kernel as IKernelInternal, component, typeName, id, converter, services);
				var registration = Component.For(services).ImplementedBy(type);
				if (component.Attributes["id-automatic"] == true.ToString())
				{
					container.Register(registration.NamedAutomatically(id));
				}
				else
				{
					container.Register(registration.Named(id));
				}
			}
		}
		protected virtual void SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
		{
			foreach (var facility in configurations)
			{
				var type = converter.PerformConversion<Type>(facility.Attributes["type"]);
				var facilityInstance = type.CreateInstance<IFacility>();
				Debug.Assert(facilityInstance != null);

				container.AddFacility(facilityInstance);
			}
		}
		private Type GetType(IConversionManager converter, string typeName)
		{
			if (typeName == null)
			{
				return null;
			}
			return converter.PerformConversion<Type>(typeName);
		}
		private void CollectAdditionalServices(IConfiguration component, IConversionManager converter, ICollection<Type> services)
		{
			var forwardedTypes = component.Children["forwardedTypes"];
			if (forwardedTypes == null)
			{
				return;
			}

			foreach (var forwardedType in forwardedTypes.Children)
			{
				var forwardedServiceTypeName = forwardedType.Attributes["service"];
				try
				{
					services.Add(converter.PerformConversion<Type>(forwardedServiceTypeName));
				}
				catch (ConverterException e)
				{
					throw new ComponentRegistrationException(
						string.Format("Component {0} defines invalid forwarded type.", component.Attributes["id"]), e);
				}
			}
		}
		private static IReference<IProxyGenerationHook> ObtainProxyHook(IConfiguration config, IConversionManager converter)
		{
			IProxyGenerationHook hook = null;
			if (config != null)
			{
				var hookAttrib = config.Attributes[Constants.ControlProxyHookAttrib];

				if (hookAttrib != null)
				{
					var hookComponent = ReferenceExpressionUtil.ExtractComponentName(hookAttrib);
					if (hookComponent != null)
					{
						return new ComponentReference<IProxyGenerationHook>(hookComponent);
					}

					var hookType = converter.PerformConversion<Type>(hookAttrib);

					if (hookType.Is<IProxyGenerationHook>() == false)
					{
						var message = String.Format("The specified controlProxyHook does " +
						                            "not implement the interface {1}. Type {0}",
						                            hookType.FullName, typeof(IProxyGenerationHook).FullName);

						throw new ConfigurationErrorsException(message);
					}

					hook = hookType.CreateInstance<IProxyGenerationHook>();
				}
			}

			if (hook == null)
			{
				hook = SynchronizeProxyHook.Instance;
			}

			return new InstanceReference<IProxyGenerationHook>(hook);
		}
Пример #28
0
		private static void DeserializeFacility(XmlNode node, IConfigurationStore store, IConversionManager converter)
		{
			var config = XmlConfigurationDeserializer.GetDeserializedNode(node);
			var typeName = GetRequiredAttributeValue(config, "type");
			var type = converter.PerformConversion<Type>(typeName);
			AddFacilityConfig(type.FullName, config, store);
		}
Пример #29
0
 /// <summary>
 /// Converts the specified value into the specified type.
 /// </summary>
 /// <param name="value">The string representation.</param>
 /// <param name="returnType">The return type.</param>
 /// <returns>The value converted to the specified type.</returns>
 private object ConvertSetting(string value, Type returnType)
 {
     return(_conversionManager.PerformConversion(value, returnType));
 }
Пример #30
0
		private static void DeserializeComponent(XmlNode node, IConfigurationStore store, IConversionManager converter)
		{
			var config = XmlConfigurationDeserializer.GetDeserializedNode(node);
			var id = config.Attributes["id"];
			if(string.IsNullOrEmpty(id))
			{
				var type = converter.PerformConversion<Type>(config.Attributes["type"]);
				id = type.FullName;
				config.Attributes["id"] = id;
				config.Attributes.Add("id-automatic", true.ToString());
			}
			AddComponentConfig(id, config, store);
		}
		private static Type ObtainType(String typeName, IConversionManager converter)
		{
			return (Type)converter.PerformConversion(typeName, typeof(Type));
		}
        /// <summary>
        ///     Reads the attribute "lifestyle" associated with the component configuration and tries to convert to <see cref = "LifestyleType" />
        ///     enum type.
        /// </summary>
        protected virtual bool ReadLifestyleFromConfiguration(ComponentModel model)
        {
            if (model.Configuration == null)
            {
                return(false);
            }

            var lifestyleRaw = model.Configuration.Attributes["lifestyle"];

            if (lifestyleRaw != null)
            {
                var lifestyleType = converter.PerformConversion <LifestyleType>(lifestyleRaw);
                model.LifestyleType = lifestyleType;
                switch (lifestyleType)
                {
                case LifestyleType.Singleton:
                case LifestyleType.Transient:
#if !(SILVERLIGHT || CLIENTPROFILE)
                case LifestyleType.PerWebRequest:
#endif
                case LifestyleType.Thread:
                    return(true);

                case LifestyleType.Pooled:
                    ExtractPoolConfig(model);
                    return(true);

                case LifestyleType.Custom:
                    var lifestyle = GetMandatoryTypeFromAttribute(model, "customLifestyleType", lifestyleType);
                    ValidateTypeFromAttribute(lifestyle, typeof(ILifestyleManager), "customLifestyleType");
                    model.CustomLifestyle = lifestyle;

                    return(true);

                case LifestyleType.Scoped:
                    var scopeAccessorType = GetTypeFromAttribute(model, "scopeAccessorType");
                    if (scopeAccessorType != null)
                    {
                        ValidateTypeFromAttribute(scopeAccessorType, typeof(IScopeAccessor), "scopeAccessorType");
                        model.ExtendedProperties[Constants.ScopeAccessorType] = scopeAccessorType;
                    }
                    return(true);

                case LifestyleType.Bound:
                    var binderType = GetTypeFromAttribute(model, "scopeRootBinderType");
                    if (binderType != null)
                    {
                        var binder = ExtractBinder(binderType, model.Name);
                        model.ExtendedProperties[Constants.ScopeRootSelector] = binder;
                    }
                    return(true);

                default:
                    throw new InvalidOperationException(string.Format("Component {0} has {1} lifestyle. This is not a valid value.", model.Name, lifestyleType));
                }
            }
            else
            {
                // type was not present, but we might figure out the lifestyle based on presence of some attributes related to some lifestyles
                var binderType = GetTypeFromAttribute(model, "scopeRootBinderType");
                if (binderType != null)
                {
                    var binder = ExtractBinder(binderType, model.Name);
                    model.ExtendedProperties[Constants.ScopeRootSelector] = binder;
                    model.LifestyleType = LifestyleType.Bound;
                    return(true);
                }
                var scopeAccessorType = GetTypeFromAttribute(model, "scopeAccessorType");
                if (scopeAccessorType != null)
                {
                    ValidateTypeFromAttribute(scopeAccessorType, typeof(IScopeAccessor), "scopeAccessorType");
                    model.ExtendedProperties[Constants.ScopeAccessorType] = scopeAccessorType;
                    model.LifestyleType = LifestyleType.Scoped;
                    return(true);
                }
                var customLifestyleType = GetTypeFromAttribute(model, "customLifestyleType");
                if (customLifestyleType != null)
                {
                    ValidateTypeFromAttribute(customLifestyleType, typeof(ILifestyleManager), "customLifestyleType");
                    model.CustomLifestyle = customLifestyleType;
                    model.LifestyleType   = LifestyleType.Custom;
                    return(true);
                }
            }
            return(false);
        }
		protected virtual void SetUpComponents(IConfiguration[] configurations, IWindsorContainer container,
		                                       IConversionManager converter)
		{
			foreach (IConfiguration component in configurations)
			{
				var id = component.Attributes["id"];

				var typeName = component.Attributes["type"];
				var serviceTypeName = component.Attributes["service"];

				if (string.IsNullOrEmpty(typeName))
				{
					continue;
				}

				var type = converter.PerformConversion<Type>(typeName);
				var service = type;

				if (!string.IsNullOrEmpty(serviceTypeName))
				{
					service = converter.PerformConversion<Type>(serviceTypeName);
				}

				AssertImplementsService(id, service, type);

				Debug.Assert(id != null);
				Debug.Assert(type != null);
				Debug.Assert(service != null);

				container.Register(Component.For(service).ImplementedBy(type).Named(id));
				SetUpComponentForwardedTypes(container.Kernel as IKernelInternal, component, typeName, id, converter);
			}
		}