This code should get you started, though hazy on some details and I don't have a compiler here: it makes reasonable assumptions and uses a custom type converter. When this is registered, it's used to do the actual conversion whenever you map from an input object to a mapped object.
public class CarTypeConverter : ITypeConverter<input, mapped>
{
public mapped Convert(ResolutionContext context)
{
// get the input object from the context
input inputCar = (input)context.SourceValue;
// get the main car
CarDTO mappedMainCar = Mapper.Map<Car, CarDTO>(input.mainCar);
mappedMainCar.carType = EnumCarType.Main;
// create a list with the main car, then add the rest
var mappedCars = new List<CarDTO> { mappedMainCar };
mappedCars.AddRange(Mapper.Map<Car, CarDTO>(inputCar.otherCars));
return new mapped { cars = mappedCars };
}
}
// In Automapper initialization
mapperCfg.CreateMap<input, mapped>().ConvertUsing<CarTypeConverter>();
mapperCfg.CreateMap<Car, CarDTO>()
.ForMember(dest => dest.carType, opt => EnumCarType.Other);