private IFactoryConfiguration ConfigureFactory(XmlNode configNode, IContainer container)
        {
            string factoryName = configNode.Attributes["name"].Value;
            string factoryMethodName = configNode.Attributes["method"].Value;
            IFactoryConfiguration factoryConfig = GetFactoryConfiguration(factoryName, container);
            factoryConfig.Name = factoryName;
            factoryConfig.MethodName = factoryMethodName;

            if (configNode.Attributes["type"] != null) //
            {
                string objectTypeString = configNode.Attributes["type"].Value;
                Type objectType = ResolveType(objectTypeString);

                factoryConfig.Type = objectType;
            }
            else if (configNode.Attributes["object"] != null) //instance
            {
                string objectName = configNode.Attributes["object"].Value;
                IObjectConfiguration objectConfig = GetObjectConfiguration(objectName, container);
                factoryConfig.Object = objectConfig;
            }

            foreach (XmlNode factoryNode in configNode)
            {
                #region Parameter

                if (factoryNode.Name == "parameter")
                {
                    ParameterConfiguration parameterConfig = new ParameterConfiguration();
                    parameterConfig.Index = Convert.ToInt32(factoryNode.Attributes["index"].Value);

                    if (factoryNode.Attributes["value"] != null)
                    {
                        string propertyValueString = factoryNode.Attributes["value"].Value;
                        ValueConfiguration propertyValueConfig = new ValueConfiguration();
                        if (factoryNode.Attributes["type"] != null)
                        {
                            //typed parameter
                            string parameterTypeString = factoryNode.Attributes["type"].Value;
                            Type parameterType = ResolveType(parameterTypeString);
                            parameterConfig.Type = parameterType;
                            propertyValueConfig.Value = Convert.ChangeType(propertyValueString, parameterConfig.Type);
                        }
                        else
                        {
                            //untyped parameter
                            propertyValueConfig.Value = propertyValueString;
                            //		parameterConfig.UntypedStringValue = propertyValueString;
                            parameterConfig.Type = null;
                        }

                        parameterConfig.Value = propertyValueConfig;

                    }

                    if (factoryNode.Attributes["object"] != null)
                    {
                        string parameterObjectName = factoryNode.Attributes["object"].Value;
                        IObjectConfiguration propertyObjectConfig = GetObjectConfiguration(parameterObjectName, container);

                        parameterConfig.Value = propertyObjectConfig;

                        //done
                        if (factoryNode.Attributes["instance-mode"] != null)
                        {
                            string instanceModeString = factoryNode.Attributes["instance-mode"].Value;
                            parameterConfig.InstanceMode = (InstanceMode) InstanceMode.Parse(typeof (InstanceMode), instanceModeString);
                        }
                    }

                    factoryConfig.ParameterConfigurations.Add(parameterConfig);
                }

                #endregion
            }

            return factoryConfig;
        }
        private void ConfigureElement(XmlNode node, ElementConfiguration config, IContainer container, Type valueType)
        {
            config.Type = valueType;

            if (node.Attributes["value"] != null)
            {
                string propertyValueString = node.Attributes["value"].Value;

                ValueConfiguration propertyValueConfig = new ValueConfiguration();
                propertyValueConfig.Value = propertyValueString;
                config.Value = propertyValueConfig;

                if (node.Attributes["type-converter"] != null)
                {
                    string typeConverterString = node.Attributes["type-converter"].Value;
                    Type typeConverterType = ResolveType(typeConverterString);

                    TypeConverter typeConverter = (TypeConverter) Activator.CreateInstance(typeConverterType);
                    propertyValueConfig.TypeConverter = typeConverter;
                }

                if (node.Attributes["type"] != null)
                {
                    string typeString = node.Attributes["type"].Value;
                    Type type = ResolveType(typeString);

                    config.Type = type;
                }
            }

            if (node.Attributes["object"] != null)
            {
                string propertyObjectName = node.Attributes["object"].Value;
                IObjectConfiguration propertyObjectConfig = GetObjectConfiguration(propertyObjectName, container);

                config.Value = propertyObjectConfig;

                //done
                if (node.Attributes["instance-mode"] != null)
                {
                    string instanceModeString = node.Attributes["instance-mode"].Value;
                    config.InstanceMode = (InstanceMode) InstanceMode.Parse(typeof (InstanceMode), instanceModeString);
                }
            }

            if (node.Attributes["list"] != null)
            {
                string propertyListName = node.Attributes["list"].Value;
                IListConfiguration propertyListConfig = GetListConfiguration(propertyListName, container);

                config.Value = propertyListConfig;
                config.Type = typeof (IList);
            }

            if (node.Attributes["factory"] != null)
            {
                string itemFactoryName = node.Attributes["factory"].Value;
                IFactoryConfiguration propertyFactoryConfig = GetFactoryConfiguration(itemFactoryName, container);

                config.Value = propertyFactoryConfig;
            }
        }