依赖下载
Autofac

Autofac.Extensions.DependencyInjection

环境搭建
创建接口

创建实现类

服务注册
ini
// 指定provider的工厂为AutofacServiceProviderFactory
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
builder.Host.ConfigureContainer<ContainerBuilder>(ConfigurationBinder =>
{
// 注册ioc
ConfigurationBinder.RegisterType<UserService>().As<IUserService>();
});

测试

