Hi

I've made this installer for initializing AutoMapper:

    public class AutoMapperInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container,
IConfigurationStore store)
        {
            container.Register(Component.For<Configuration,
IConfiguration, IConfigurationProvider>()
                                   .ImplementedBy<Configuration>()
                                   
.DependsOn(Property.ForKey("mappers").Eq(MapperRegistry.AllMappers())));

 
container.Register(AllTypes.FromAssemblyContaining<IAutoMapper>().BasedOn<IAutoMapper>().WithService.FirstInterface());

            foreach (var mapper in
container.ResolveAll<IAutoMapper>())
            {
                mapper.Configure();
            }
        }
    }

My implementation of IAutoMapper is the following:

    public class DaMapper : IAutoMapper
    {
        public IConfiguration Configuration { get; set; }

        public void Configure()
        {
            Configuration.CreateMap<BuildingPart, BuildingPartDTO>()
                .ForMember(x => x.Title, opt => opt.MapFrom(x =>
x.ShortText));
        }
    }

When running the last foreach in the install (using ResolveAll in the
installer) the property won't be injected. If I change the
implementation of IAutoMapper to use ctor injection it will be
injected.

What is the difference? Why can't I use property injection properly
here? Is it a bug or me misusing the installer?

My thought would be, that this kind of initialization using the
container should not be done in an installer. If that's the case,
where would be the appropriate place?

Regards, Asger

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to