November 16, 2009 22:05
For a project I’m currently consulting on I thought it might be a good idea to have a closer look at AutoMapper and since the IOC Container of choice at the project is Autofac, finding a title for this post wasn’t that difficult :-).
First thing we wanted to do was wrap the AutoMapper method calls in a way that would allow us to write our own custom mapping if we wanted to for special cases, so this is what we came up with:

And for the implementation:

This should allow us to do something like this with Autofac:

Since in a lot of cases we wanted to do the mapping both ways, we seemed to be missing this method:

Which should allow us to construct a mapping like this:

So far so good...