IServiceCollection override a single constructor argument

后端 未结 3 1927
执念已碎
执念已碎 2021-01-05 03:41

I have a class that takes three constructor arguments. In my composition root I want to define/override only one of the three constructor arguments; the oth

3条回答
  •  死守一世寂寞
    2021-01-05 04:07

    Example:
    Service Cons.:

    public SkillsService(IRepositoryBase repositoryCategory, int categoryId)
    

    Startup:

     services.AddScoped(i => new SkillsService(services.BuildServiceProvider().GetService>(), AppSettingsFeatures.Skills));
    

提交回复
热议问题