Injecting AutoMapper dependencies using Ninject?

It might also be a good idea to introduce a mapping facade. Instead of passing IMappingEngine through out your code create an IObjectMapper interface. The interface I use contains method signatures taken directly out of automappers code.

It might also be a good idea to introduce a mapping facade. Instead of passing IMappingEngine through out your code create an IObjectMapper interface. The interface I use contains method signatures taken directly out of automappers code.

Public interface IObjectMapper { TDestination Map(TSource source); TDestination Map(TSource source, TDestination destination); object Map(object source, Type sourceType, Type destinationType); object Map(object source, object destination, Type sourceType, Type destinationType); } Your configuration is still going to be automapper dependent. A blog post I wrote on it is here: http://fodonnel.wordpress.com/2010/09/20/an-object-mapper-facade.

I got it working but it doesn't feel very clean creating an instance of the Configuration class. Any suggestions to clean it up further. Bind().To(); Bind().

ToConstant(new Configuration(Kernel.Get(), MapperRegistry.AllMappers())). InSingletonScope(); Bind(). ToMethod(c => c.Kernel.Get()); Bind().

ToMethod(c => c.Kernel.Get()); Bind().To().

Best to edit this into your question. In general I'd say you're overusing Bind(). ToMethod(c => c.Kernel.Get().

Just use Bind().To() – Ruben Bartelink Sep 2 '10 at 8:01 Ditto Bind(). ToConstant(new Configuration(Kernel.Get(), MapperRegistry.AllMappers())). InSingletonScope(); should map to .To.

WithConstructorArgument.... – Ruben Bartelink Sep 2 '10 at 8:09.

(Not checked but translated from post:- ForRequestedType() . CacheBy(InstanceScope. Singleton) .

TheDefault.Is.OfConcreteType() . CtorDependency>(). Is(expr => expr.

ConstructedBy(MapperRegistry. AllMappers)); would be something like: Bind.ToSelf(). WithConstructorArgument( MapperRegistry.

AllMappers); (you'll probably need to add an arg name) (The MapperRegistry,. AllMappers bit is:- public static class MapperRegistry { public static Func> AllMappers = () => new IObjectMapper { new CustomTypeMapMapper(), ... new TypeConverterMapper(), new NullableMapper(), }; }.

Ruben, I have already defined the Constructor binding as: Bind().ToSelf(). InSingletonScope(). WithConstructorArgument("mappe?

R", MapperRegistry. AllMappers); – Corey Coto Sep 1 '10 at 16:11.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions