wep api 2 加入 autofac and automapper 依賴注入

  • 87
  • 0

wep api 2 加入 依賴注入

專案底下加入 autofac and automapper

1.

Install-Package Autofac -Version 4.9.4

2.

Install-Package AutoMapper -Version 9.0.0

3. 加入 autofacConfig , automapperModule

automapperModule 繼承aufac Module

autofacconfig.cs 內容 ,注入 di的內容

createMap 的 繼承profile

參考

https://docs.autofac.org/en/latest/configuration/modules.html

http://www.protomatter.co.uk/blog/development/2017/02/modular-automapper-registrations-with-autofac/