using System; using System.Linq; using System.Collections.Generic; using AutoMapper; namespace Taloyhtio.GeneralApi.Core.Infrastructure.AutoMapper { public class AutoMapperConfiguration { // public static Func CreateDependencyCallback = (type) => Activator.CreateInstance(type); public static void Configure() { Mapper.Initialize(x => { // x.ConstructServicesUsing(type => CreateDependencyCallback(type)); GetProfiles().ToList().ForEach(type => x.AddProfile((Profile) Activator.CreateInstance(type))); }); } private static IEnumerable GetProfiles() { foreach (Type type in typeof (AutoMapperConfiguration).Assembly.GetTypes()) { if (!type.IsAbstract && typeof (Profile).IsAssignableFrom(type)) yield return type; } } // void IRequiresConfigurationOnStartup.Configure() // { // Configure(); // // AutoMappedViewResult.Map = (a, b, c) => Mapper.Map(a, b, c); // } } }