Resolving AutoMapper IMappingEngine

Nov 16, 2011 at 9:40 PM

I see that Bootstrapper.AutoMapper registers IMappingEngine, but ServiceLocator doesn't return an instance of MappingEngine.

            Bootstrap.Bootstrapper
                .With.Unity()
                .And.AutoMapper()
                .And.ServiceLocator()
                .Start();

What am I missing?

Coordinator
Nov 28, 2011 at 3:30 AM

Hi,

Unfortunately I'm not superfamiliar with the way Unity works. This shows on the number of issues I get related with the Unity extension.

I was able to make this work with the following code. The commented out lienes don't work. The reason is that in my implementation of the Unity extension I use the class name as the key for the registration. Therefore you need to provide the name when Resolving a type. It's kind of sucky, I know....

 

Bootstrapper
   .With.Unity()
   .And.AutoMapper()
   .And.ServiceLocator()
   .Start();

var mapper = ServiceLocator.Current.GetInstance(typeof(IMappingEngine), "MappingEngine");