Skip to content

Instantly share code, notes, and snippets.

@thiagomajesk
Created January 25, 2018 13:05
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 thiagomajesk/e2440ec1cbc334460f4cb2ecaeb51f69 to your computer and use it in GitHub Desktop.
Save thiagomajesk/e2440ec1cbc334460f4cb2ecaeb51f69 to your computer and use it in GitHub Desktop.
AutoMapper configuration for AutoFac
public class AutoMapperModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.Register(c => new MapperConfiguration(config => { config.AddProfiles(GetType().Assembly); })).AsSelf().SingleInstance();
builder.Register(c => c.Resolve<MapperConfiguration>().CreateMapper(c.Resolve)).As<IMapper>().InstancePerLifetimeScope();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment