builder.RegisterAssemblyTypes(typeof(IProductService).Assembly).Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces();

 备注:

a. 如果 IProductService 有 2 个实现类,那么运行时用到 IProductService 会抛出异常。

b. 如果 IProductService 有 2 个实现类,ProductService1 和 ProductService2(抽象类),那么 Autofac 自动采用 ProductService1 作为实现类。

 

2. 未完待续...

谢谢浏览!

相关文章:

  • 2021-12-02
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2021-08-10
  • 2021-12-27
  • 2021-05-31
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案