2
votes

Could I call the Mapper.CreateMap in each Initialize method of the prism modules to configure the map for objects in different modules? I prefer this method so the module and mappings can be developed seperately

Or should I call the Mapper.CreateMap in one central place which is probably in bootstrapper? It is in bootstrapper, in which override method of the MEFbootstrapper is best?

1

1 Answers

0
votes

I know this question is very old, but I was wondering the same thing and I came across your question. In the current state of things (Prism 5 & AutoMapper 3.2.1) you CAN create your mappings in your module definition for each prism module.

 public void Initialize()
    {
        this.RegisterViewsAndServices();
        this.ResolveAutomapping();
    }

 private void ResolveAutomapping()
    {
        AutoMapper.Mapper.CreateMap<Entities.Channel, Modules.EntityWrappers.ChannelWrapper>().ForMember("Selected", o => o.UseValue(false));
    }

In my viewmodel I then call this with no issue

Channels = new ObservableCollection<ChannelWrapper>(data.Select(r => AutoMapper.Mapper.Map<ChannelWrapper>(r)));