I need to use Unity
as my DI container and want to bootstrap AutoMapper
.
Using StructureMap
I can do it like this;
For<IMappingEngine>().Use(() => Mapper.Engine);
How do I do this in Unity
?
I have used the Package Manager to get hold of the currently newest version of AutoMapper
2.2.1-ci9000, but could also use 2.2.0 in case that is simpler. I use version 2.1.505.0 of Microsoft.Practices.Unity
.
This should work:
container.RegisterType<IMappingEngine>(new InjectionFactory(_ => Mapper.Engine));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With