/// <summary> /// All these map puns are giving me a headache. /// </summary> internal static void Mapptivate(Mapptribute mapsToAttribute, Type sourceType, Type targetType, IMapperConfigurationExpression mapperConfiguration, Type[] types, bool reverseMap) { var mappedProperties = GetMappedProperties(types, sourceType, targetType); var mappingExpression = MapTypes(sourceType, targetType, mappedProperties, mapperConfiguration); //if a ConfigureMapping method is defined, call it var configureMappingGenericMethod = GetConfigureMappingGenericMethod(mapsToAttribute, sourceType, targetType); configureMappingGenericMethod?.Invoke(mapsToAttribute, new[] { mappingExpression }); if (reverseMap) { Mapptivate(mapsToAttribute, targetType, sourceType, mapperConfiguration, types, false); } }
private static MethodInfo GetConfigureMappingGenericMethod(Mapptribute mapsToAttribute, Type sourceType, Type targetType) { return(mapsToAttribute.GetType() .GetMethod("ConfigureMapping", new[] { typeof(IMappingExpression <,>).MakeGenericType(sourceType, targetType) })); }