using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentNHibernate.Mapping;

namespace FluentNHibernate.AutoMap
{
    public class AutoMapper
    {
        private readonly List<IAutoMapper> _mappingRules;

        public AutoMapper(Conventions conventions)
        {
            _mappingRules = new List<IAutoMapper>
                                {
                                    new AutoMapIdentity(conventions), 
                                    new AutoMapVersion(conventions), 
                                    new AutoMapColumn(conventions),
                                    new AutoMapManyToOne(conventions),
                                    new AutoMapOneToMany(conventions),
                                };
        }

        public AutoMap<T> MergeMap<T>(AutoMap<T> map)
        {
            foreach (var property in typeof(T).GetProperties())
            {
                if (!property.PropertyType.IsEnum)
                {
                    foreach (var rule in _mappingRules)
                    {
                        if (rule.MapsProperty(property))
                        {
                            if (map.PropertiesMapped.Count(p => p.Name == property.Name) == 0)
                            {
                                rule.Map(map, property);
                                break;
                            }
                        }
                    }
                }
            }
            return map;
        }

        public AutoMap<T> Map<T>()
        {
            var classMap = (AutoMap<T>)Activator.CreateInstance(typeof(AutoMap<T>));
            return MergeMap(classMap);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentNHibernate.Mapping;

namespace FluentNHibernate.AutoMap
{
    public class AutoMapper
    {
        private readonly List<IAutoMapper> _mappingRules;

        public AutoMapper(Conventions conventions)
        {
            _mappingRules = new List<IAutoMapper>
                                {
                                    new AutoMapIdentity(conventions), 
                                    new AutoMapVersion(conventions), 
                                    new AutoMapColumn(conventions),
                                    new AutoMapManyToOne(conventions),
                                    new AutoMapOneToMany(conventions),
                                };
        }

        public AutoMap<T> MergeMap<T>(AutoMap<T> map)
        {
            foreach (var property in typeof(T).GetProperties())
            {
                if (property.PropertyType.IsClass)
                {
                    foreach (var rule in _mappingRules)
                    {
                        if (rule.MapsProperty(property))
                        {
                            if (map.PropertiesMapped.Count(p => p.Name == property.Name) == 0)
                            {
                                rule.Map(map, property);
                                break;
                            }
                        }
                    }
                }
            }
            return map;
        }

        public AutoMap<T> Map<T>()
        {
            var classMap = (AutoMap<T>)Activator.CreateInstance(typeof(AutoMap<T>));
            return MergeMap(classMap);
        }
    }
}
Change automapper to whitelist classes rather than blacklist enums.
Change automapper to whitelist classes rather than blacklist enums.

git-svn-id: a161142445158cf41e00e2afdd70bb78aded5464@74 48f0ce17-cc52-0410-af8c-857c09b6549b
