How do I validate configuration with the automapper Instance API

Viewed 5181

I know that using automapper's static API I can do this:

Mapper.Initialize(cfg => 
  cfg.CreateMap<Source, Destination>());

Mapper.Configuration.AssertConfigurationIsValid();

but now I've switched to the instance API:

var config = new MapperConfiguration(cfg => {
    cfg.AddProfile<AppProfile>();
    cfg.CreateMap<Source, Dest>();
});

var mapper = config.CreateMapper();

How/where can I check if the configuration is valid using the instance API?

1 Answers

You can also do the validation using:

mapper.ConfigurationProvider.AssertConfigurationIsValid();
Related