public DefaultComponentModel(
            ComponentData data,
            Type service,
            ILogger logger,
            IConfiguration configuration,
            IConstructionModel constructionModel)
            : this()
        {
            AssertUtil.ArgumentNotNull(data, "data");
            AssertUtil.ArgumentNotNull(service, "service");
            AssertUtil.ArgumentNotNull(logger, "logger");
            AssertUtil.ArgumentNotNull(configuration, "configuration");
            AssertUtil.ArgumentNotNull(constructionModel, "constructionModel");

            m_name = data.Name;
            m_service = service;
            m_constructionModel = constructionModel;
            SupportedLifestyle = data.SupportedLifestyle;
            ActivationPolicy = data.ActivationPolicy;
            Logger = logger;
            Configuration = configuration;
            Dependencies = data.DependencyModel;
        }
        protected void InspectSetMethods( Type service, ComponentData componentData )
        {
            PropertyInfo[] properties = service.GetProperties();

            foreach(PropertyInfo property in properties)
            {
                if (IsEligible( property ))
                {
                    AddDependency( componentData.Dependencies, property.PropertyType );
                    componentData.Properties.Add( property );
                }
            }
        }
        protected void InspectConstructors( ComponentData componentData )
        {
            ConstructorInfo constructor = null;

            ConstructorInfo[] constructors = componentData.Implementation.GetConstructors();

            // TODO: Try to sort the array
            // by the arguments lenght in descendent order

            foreach(ConstructorInfo item in constructors)
            {
                if (IsEligible( item ))
                {
                    constructor = item;

                    ParameterInfo[] parameters = constructor.GetParameters();

                    foreach(ParameterInfo parameter in parameters)
                    {
                        if (!parameter.ParameterType.IsInterface)
                        {
                            continue;
                        }

                        AddDependency( componentData.Dependencies, parameter.ParameterType );
                    }

                    break;
                }
            }

            if ( constructor == null )
            {
                throw new ModelBuilderException(
                    String.Format("Handler could not find an eligible constructor for type {0}",
                    componentData.Implementation.FullName) );
            }

            componentData.Constructor = constructor;
        }
        protected void InspectAvalonAttributes( ComponentData componentData )
        {
            if (!componentData.Implementation.IsDefined( typeof(AvalonComponentAttribute), false ))
            {
                return;
            }

            componentData.AvalonComponent = GetComponentAttribute( componentData.Implementation );
            componentData.AvalonLogger = GetLoggerAttribute( componentData.Implementation );
            AvalonDependencyAttribute[] dependencyAttributes = GetDependencyAttributes( componentData.Implementation );

            foreach( AvalonDependencyAttribute dependency in dependencyAttributes )
            {
                AddDependency( componentData.Dependencies, dependency.DependencyType,
                    dependency.Key, dependency.IsOptional );
            }
        }
        protected virtual ILogger CreateLogger( ComponentData data )
        {
            ILoggerManager loggerManager = (ILoggerManager)
                m_kernel.GetSubsystem( KernelConstants.LOGGER );

            if(loggerManager != null)
            {
                return loggerManager.CreateLogger(
                    data.Name, data.Implementation.Name, data.AvalonLogger );
            }
            else
            {
                return new ConsoleLogger( data.Name, LoggerLevel.Info );
            }
        }
        protected virtual IConfiguration CreateConfiguration( ComponentData data )
        {
            IConfigurationManager configManager = (IConfigurationManager)
                m_kernel.GetSubsystem( KernelConstants.CONFIGURATION );

            if( configManager != null )
            {
                return configManager.GetConfiguration( data.Name );
            }
            else
            {
                return new DefaultConfiguration();
            }
        }
        public IComponentModel BuildModel(String key, Type service, Type implementation)
        {
            AssertUtil.ArgumentNotNull( key, "key" );
            AssertUtil.ArgumentNotNull( service, "service" );
            AssertUtil.ArgumentNotNull( implementation, "implementation" );

            ComponentData data = new ComponentData( key, implementation );

            InspectConstructors(data);
            InspectSetMethods(service, data);
            InspectAvalonAttributes(data);

            IConstructionModel constructionModel =
                new DefaultConstructionModel( implementation, data.Constructor, data.PropertiesInfo );

            ILogger logger = CreateLogger( data );
            IConfiguration config = CreateConfiguration( data );

            return new DefaultComponentModel( data, service, logger, config, constructionModel );
        }