Ioc:The basic pattern for integrating Autofac into your application

The basic pattern for integrating Autofac into your application is:

  • Structure your app with inversion of control (IoC) in mind.
  • Add Autofac references.
  • At application startup...
  • Create a ContainerBuilder.
  • Register components.
  • Build the container and store it for later use.
  • During application execution...
  • Create a lifetime scope from the container.
  • Use the lifetime scope to resolve instances of the components.
原文地址:https://www.cnblogs.com/happyframework/p/4046940.html