Ioc:Autofac Registration Concepts

Reflection Components

When using reflection-based components, Autofac automatically uses the constructor for your class with the most parameters that are able to be obtained from the container.

Instance Components

Something to consider when you register the instance is that Autofac automatically handles disposal of registered components and you may want to control the lifetime yourself rather than having Autofac call Disposeon your object for you. In that case, you need to register the instance with the ExternallyOwnedmethod.

Default Registrations

If more than one component exposes the same service, Autofac will use the last registered component as the default provider of that service.

 

你可能感兴趣的:(auto)