Created
January 25, 2018 13:05
-
-
Save thiagomajesk/e2440ec1cbc334460f4cb2ecaeb51f69 to your computer and use it in GitHub Desktop.
AutoMapper configuration for AutoFac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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