public static ContainerBuilder WithMapper(this ContainerBuilder containerBuilder) { Action <Container> action = container => { var configurer = new MapperConfigurer(); RegisterProviders(configurer); container.Register(new Mapper(configurer)); }; containerBuilder.RegisterAction(action); return(containerBuilder); }
private static void RegisterProviders(MapperConfigurer configurer) { IEnumerable <Type> mappingProvidersTypes = Reflection .GetTypesInheritedFrom <IMappingProvider>() .Where(type => type != typeof(MappingProvider <,>)); foreach (Type providerType in mappingProvidersTypes) { IMappingProvider provider = (IMappingProvider)Activator.CreateInstance(providerType); Type[] genericArguments = providerType.BaseType.GetGenericArguments(); configurer.RegisterProvider(genericArguments[0], genericArguments[1], provider); } }
internal Mapper(MapperConfigurer configurer) { _dict = configurer.ProvidersConfiguration; }