Unity constructor injection with other parameter

前端 未结 3 585
悲&欢浪女
悲&欢浪女 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:01

    You can use ParameterOverride:

    BatchService batchService = 
    DIContainer.Resolve(new ParameterOverride("user", valueForUser));
    

提交回复
热议问题