Skip to content

Instantly share code, notes, and snippets.

@jbogard
Created December 17, 2020 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbogard/2898a35fefd1165b511642402c07a2d6 to your computer and use it in GitHub Desktop.
Save jbogard/2898a35fefd1165b511642402c07a2d6 to your computer and use it in GitHub Desktop.
public static class AutoMapperConfiguration
{
public static MapperConfiguration Config { get; private set; }
public static void Configure()
{
// Note below, you don't have to call AddProfile. You can call AddMaps, passing in Assembly object to search for Profiles
Config = new MapperConfiguration(cfg => {
/* list of assemblies to scan for profiles */
cfg.AddProfile<ViewModelMaps.AdminViewModelMaps>();
cfg.AddProfile<ViewModelMaps.OrderViewModelMaps>();
cfg.AddProfile<ViewModelMaps.ITemViewModelMaps>();
...
...
});
Config.AssertConfigurationIsValid();
}
public static Mapper GetMapper()
{
return Config.CreateMapper();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment