Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 internal Mapper(MapperConfigurer configurer)
 {
     _dict = configurer.ProvidersConfiguration;
 }