Last active
July 19, 2019 06:07
-
-
Save gethari/5a58a4ade90be08808af6a306bfddb28 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.RegisterAssemblyTypes(typeof(AutoMapperModule).Assembly).As < Profile > (); | |
builder.Register(context => new MapperConfiguration(cfg => { | |
foreach(var profile in context.Resolve < IEnumerable < Profile >> ()) { | |
cfg.AddProfile(profile); | |
} | |
})).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