Given the following:
var object1 = new A() { Equipment = new List<FooEquipment>() { new FooEquipment() } };
var object2 = new B() { Equipment = new List<FooEquipment>() { new FooEquipment() } );
var list = new List<Foo>() { object1, object2 };
(I've inherited some legacy code, the List should be in the base class of A and B).
With some new classes,
public class AFooEquipment : FooEquipment
{
}
public class BFooEquipment : FooEquipment
{
}
Can I use AutoMapper to convert these FooEquipments
into AFooEquipment
and BFooEquipment
by inspecting their parent item somehow? I.e. In the mapper I would see object1 is in a typeof(A) class, so I convert its equipment -> List<AFooEquipment>
. It would see object2 is in a typeof(B) class, so I convert its equipment -> List<BFooEquipment>
.
Is that possible?