Unity constructor injection with other parameter

前端 未结 3 583
悲&欢浪女
悲&欢浪女 2021-01-04 12:37

I have a class with a constructor that looks like the following:

public BatchService(IRepository repository, ILogger logger, string user)

I

3条回答
  •  长发绾君心
    2021-01-04 13:12

    First of all it's not good idea mix ILogger with business logic. You can create ILogger directly in BatchService or resolve thru [Dependency] attribute. DI it's not panacea, business object creation shouldn't depend from ILogger

    Use new InjectionParameter("user") Take a look please Registering Injected Parameter and Property Values for more details

提交回复
热议问题