Dependency Injection (DI) Support #1244
-
Does mapperly support mapping to classes that have DI constructors? public class BO
{
public BO(IAmADependent b)
{
dependent = b;
}
private IAmADependent dependent;
}
public class DTO
{
}
[Mapper]
public partial class BOMapper
{
public static partial BO MapBO(DTO dto);
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You can simply use an object factory. |
Beta Was this translation helpful? Give feedback.
-
I've read through the documentation on object factory but do not seem to understand. I cannot access the In the example provided // or an object factory which will create objects for all types
[ObjectFactory]
private T Create<T>()
=> _diContainer.Resolve<T>(); where does Do you have an example? :D |
Beta Was this translation helpful? Give feedback.
You simply inject
_diContainer
into your mapper.Example: