public virtual IEnumerable<AbstractPropertyConfiguration> AutoMapProperties(Type type)
{
BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance |
BindingFlags.FlattenHierarchy;
IEnumerable<PropertyInfo> properties = type.GetProperties(flags);
if (type.IsInterface)
{
foreach (var inter in type.GetInterfaces())
{
properties = properties.Union(inter.GetProperties(flags));
}
}
var propList = new List<AbstractPropertyConfiguration>();
foreach (var property in properties)
{
if (Properties.All(x => x.PropertyInfo != property))
{
//skipped already mapped properties
if(_properties.Any(x=>x.PropertyInfo.Name == property.Name))
continue;
//skip properties that are actually indexers
if (property.GetIndexParameters().Length > 0)
{
continue;
}
//check for an attribute
var propConfig = AttributeTypeLoader.ProcessProperty(property);
if (propConfig == null)
{
//no attribute then automap
propConfig = AutoMapProperty(property);
}
if (propConfig != null)
propList.Add(propConfig);
}
}
return propList;
}